1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-26 15:52:20 +01:00
2021-07-01 12:04:48 +02:00

17 lines
578 B
TypeScript

import apiClient from './clients/api-client';
import { AxiosResponse } from 'axios';
import { Group, GroupIndexFilter } from '../models/group';
export default class GroupAPI {
static async index (filters?: GroupIndexFilter): Promise<Array<Group>> {
const res: AxiosResponse<Array<Group>> = await apiClient.get(`/api/groups${this.filtersToQuery(filters)}`);
return res?.data;
}
private static filtersToQuery (filters?: GroupIndexFilter): string {
if (!filters) return '';
return '?' + Object.entries(filters).map(f => `${f[0]}=${f[1]}`).join('&');
}
}