Added retries on failed api requests
This commit is contained in:
parent
91a8f03749
commit
79a3e508dc
2 changed files with 4 additions and 4 deletions
|
|
@ -6,9 +6,9 @@ export default async (api: string, value?: any) => {
|
||||||
try {
|
try {
|
||||||
let fetch
|
let fetch
|
||||||
if (!value) {
|
if (!value) {
|
||||||
fetch = await ofetch(API + api, { parseResponse: JSON.parse })
|
fetch = await ofetch(API + api, { parseResponse: JSON.parse, retry: 3, retryDelay: 500, retryStatusCodes: [400, 404, 405, 500, 502] })
|
||||||
} else {
|
} else {
|
||||||
fetch = await ofetch(API + `${api}/${value}`, { parseResponse: JSON.parse })
|
fetch = await ofetch(API + `${api}/${value}`, { parseResponse: JSON.parse, retry: 3, retryDelay: 500, retryStatusCodes: [400, 404, 405, 500, 502] })
|
||||||
}
|
}
|
||||||
const result = fetch.result
|
const result = fetch.result
|
||||||
return result
|
return result
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@ export default async (api: string, value?: any) => {
|
||||||
let fetch
|
let fetch
|
||||||
try {
|
try {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
fetch = await ofetch(API + api, { parseResponse: JSON.parse })
|
fetch = await ofetch(API + api, { parseResponse: JSON.parse, retry: 3, retryDelay: 500, retryStatusCodes: [400, 404, 405, 500, 502] })
|
||||||
} else {
|
} else {
|
||||||
fetch = await ofetch(API + `${api}/${value}`, { parseResponse: JSON.parse })
|
fetch = await ofetch(API + `${api}/${value}`, { parseResponse: JSON.parse, retry: 3, retryDelay: 500, retryStatusCodes: [400, 404, 405, 500, 502] })
|
||||||
}
|
}
|
||||||
|
|
||||||
return fetch
|
return fetch
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue