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

22 lines
566 B
TypeScript
Raw Normal View History

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