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 {
|
||||
let fetch
|
||||
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 {
|
||||
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
|
||||
return result
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ export default async (api: string, value?: any) => {
|
|||
let fetch
|
||||
try {
|
||||
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 {
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue