From f985c041e47f5ff10227f0cbcf250cc23f87bdf5 Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Tue, 30 Dec 2025 22:26:43 +0700 Subject: [PATCH] chore: create getAll method in BaseApiService --- src/services/api/base.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/services/api/base.ts b/src/services/api/base.ts index 2fcf3712..6a3fdfa4 100644 --- a/src/services/api/base.ts +++ b/src/services/api/base.ts @@ -15,6 +15,22 @@ export class BaseApiService { return await httpClientFetcher>(endpoint); } + async getAll(query?: Record) { + try { + const getAllPath = this.basePath; + const getAllRes = await httpClient>(getAllPath, { + query, + }); + + return getAllRes; + } catch (error) { + if (axios.isAxiosError>(error)) { + return error.response?.data; + } + return undefined; + } + } + async getSingle(id: number) { try { const getSinglePath = `${this.basePath}/${id}`;