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 {