Updated function

This commit is contained in:
Patrick Alvin Alcala 2025-11-05 12:23:21 +08:00
parent 40f2ad04f4
commit b19acd6343

View file

@ -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 {