This commit is contained in:
Patrick Alvin Alcala 2025-11-20 13:03:40 +08:00
parent 4184942584
commit afb5f3a287
66 changed files with 550 additions and 57 deletions

View file

@ -0,0 +1,23 @@
import { ofetch } from 'ofetch'
import { $backendUrl } from '../../../../configs/config.api'
const URL = $backendUrl.get()
export default async (api: string, value?: any, value2?: any) => {
try {
let fetch
if (!value2) {
if (!value) {
fetch = await ofetch(URL + api, { parseResponse: JSON.parse, retry: 3, retryDelay: 500, retryStatusCodes: [400, 404, 405, 500, 502] })
} else {
fetch = await ofetch(URL + `${api}/${value}/fetch-data`, { parseResponse: JSON.parse, retry: 3, retryDelay: 500, retryStatusCodes: [400, 404, 405, 500, 502] })
}
} else {
fetch = await ofetch(URL + `${api}/${value}/${value2}/fetch-data`, { parseResponse: JSON.parse, retry: 3, retryDelay: 500, retryStatusCodes: [400, 404, 405, 500, 502] })
}
const result = fetch
return [result, null]
} catch (error) {
return [[], error]
}
}