misc_pterodactyl-panel/resources/scripts/api/admin/roles/getRoles.ts

21 lines
566 B
TypeScript

import http, { FractalResponseData } from '@/api/http';
export interface Role {
id: number;
name: string;
description?: string;
}
export const rawDataToRole = ({ attributes }: FractalResponseData): Role => ({
id: attributes.id,
name: attributes.name,
description: attributes.description,
});
export default (): Promise<Role[]> => {
return new Promise((resolve, reject) => {
http.get('/api/application/roles')
.then(({ data }) => resolve((data.data || []).map(rawDataToRole)))
.catch(reject);
});
};