feat(WEB-300): add retry for fetch calls
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import fetchRetry from "fetch-retry"
|
||||
import { DocumentNode } from "graphql"
|
||||
import { GraphQLClient } from "graphql-request"
|
||||
import { cache } from "react"
|
||||
@@ -13,6 +14,12 @@ const client = new GraphQLClient(env.CMS_URL, {
|
||||
url: URL | RequestInfo,
|
||||
params: RequestInit | undefined
|
||||
) {
|
||||
const fetch = fetchRetry(global.fetch, {
|
||||
retries: 3,
|
||||
retryDelay: function (attempt, error, response) {
|
||||
return Math.pow(2, attempt) * 150 // 150, 300, 600
|
||||
},
|
||||
})
|
||||
return fetch(url, params)
|
||||
}),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user