From b19acd6343e68ae65905efec265bec13f94e2587 Mon Sep 17 00:00:00 2001 From: Patrick Alvin Alcala Date: Wed, 5 Nov 2025 12:23:21 +0800 Subject: [PATCH] Updated function --- src/utils/functions/getApi.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/utils/functions/getApi.ts b/src/utils/functions/getApi.ts index 20942e0..30b4523 100644 --- a/src/utils/functions/getApi.ts +++ b/src/utils/functions/getApi.ts @@ -2,9 +2,14 @@ import { ofetch } from 'ofetch' const API = import.meta.env.VITE_BACKEND -export default async (api: string) => { +export default async (api: string, value?: any) => { try { - const fetch = await ofetch(API + api, { parseResponse: JSON.parse }) + let fetch + if (!value) { + fetch = await ofetch(API + api, { parseResponse: JSON.parse }) + } else { + fetch = await ofetch(API + `${api}/${value}`, { parseResponse: JSON.parse }) + } const result = fetch.result return result } catch {