Added /fetch-data to api requests
This commit is contained in:
parent
8176032cb1
commit
fd4a1df6b3
2 changed files with 28 additions and 5 deletions
|
|
@ -1,14 +1,37 @@
|
|||
// import { ofetch } from 'ofetch'
|
||||
|
||||
// const API = import.meta.env.VITE_BACKEND
|
||||
|
||||
// export default async (api: string, value?: any) => {
|
||||
// try {
|
||||
// let fetch
|
||||
// if (!value) {
|
||||
// fetch = await ofetch(API + api, { parseResponse: JSON.parse, retry: 3, retryDelay: 500, retryStatusCodes: [400, 404, 405, 500, 502] })
|
||||
// } else {
|
||||
// fetch = await ofetch(API + `${api}/${value}`, { parseResponse: JSON.parse, retry: 3, retryDelay: 500, retryStatusCodes: [400, 404, 405, 500, 502] })
|
||||
// }
|
||||
// const result = fetch.result
|
||||
// return result
|
||||
// } catch {
|
||||
// return []
|
||||
// }
|
||||
// }
|
||||
|
||||
import { ofetch } from 'ofetch'
|
||||
|
||||
const API = import.meta.env.VITE_BACKEND
|
||||
|
||||
export default async (api: string, value?: any) => {
|
||||
export default async (api: string, value?: any, value2?: any) => {
|
||||
try {
|
||||
let fetch
|
||||
if (!value) {
|
||||
fetch = await ofetch(API + api, { parseResponse: JSON.parse, retry: 3, retryDelay: 500, retryStatusCodes: [400, 404, 405, 500, 502] })
|
||||
if (!value2) {
|
||||
if (!value) {
|
||||
fetch = await ofetch(API + api, { parseResponse: JSON.parse, retry: 3, retryDelay: 500, retryStatusCodes: [400, 404, 405, 500, 502] })
|
||||
} else {
|
||||
fetch = await ofetch(API + `${api}/${value}/fetch-data`, { parseResponse: JSON.parse, retry: 3, retryDelay: 500, retryStatusCodes: [400, 404, 405, 500, 502] })
|
||||
}
|
||||
} else {
|
||||
fetch = await ofetch(API + `${api}/${value}`, { parseResponse: JSON.parse, retry: 3, retryDelay: 500, retryStatusCodes: [400, 404, 405, 500, 502] })
|
||||
fetch = await ofetch(API + `${api}/${value}/${value2}/fetch-data`, { parseResponse: JSON.parse, retry: 3, retryDelay: 500, retryStatusCodes: [400, 404, 405, 500, 502] })
|
||||
}
|
||||
const result = fetch.result
|
||||
return result
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ export default async (api: string, value?: any) => {
|
|||
if (!value) {
|
||||
fetch = await ofetch(API + api, { parseResponse: JSON.parse, retry: 3, retryDelay: 500, retryStatusCodes: [400, 404, 405, 500, 502] })
|
||||
} else {
|
||||
fetch = await ofetch(API + `${api}/${value}`, { parseResponse: JSON.parse, retry: 3, retryDelay: 500, retryStatusCodes: [400, 404, 405, 500, 502] })
|
||||
fetch = await ofetch(API + `${api}/${value}/fetch-data`, { parseResponse: JSON.parse, retry: 3, retryDelay: 500, retryStatusCodes: [400, 404, 405, 500, 502] })
|
||||
}
|
||||
|
||||
return fetch
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue