mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 05:22:02 +00:00
chore: create getAll method in BaseApiService
This commit is contained in:
@@ -15,6 +15,22 @@ export class BaseApiService<T, CreatePayloadGeneric, UpdatePayloadGeneric> {
|
||||
return await httpClientFetcher<BaseApiResponse<T[]>>(endpoint);
|
||||
}
|
||||
|
||||
async getAll(query?: Record<string, unknown>) {
|
||||
try {
|
||||
const getAllPath = this.basePath;
|
||||
const getAllRes = await httpClient<BaseApiResponse<T[]>>(getAllPath, {
|
||||
query,
|
||||
});
|
||||
|
||||
return getAllRes;
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError<BaseApiResponse<T[]>>(error)) {
|
||||
return error.response?.data;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
async getSingle(id: number) {
|
||||
try {
|
||||
const getSinglePath = `${this.basePath}/${id}`;
|
||||
|
||||
Reference in New Issue
Block a user