Configuration options that control retry behavior.
A FetchMethod that automatically retries qualifying failures.
This wrapper uses a lightweight internal retry loop and an AbortController to cancel pending requests when a non-retriable error occurs.
const fetchWithRetry = createRetryFetchMethod({
apiName: 'Optimization',
retries: 3,
intervalTimeout: 200,
onFailedAttempt: ({ attemptNumber, retriesLeft }) => {
console.warn(`Attempt ${attemptNumber} failed. Retries left: ${retriesLeft}`)
},
})
const response = await fetchWithRetry('https://example.com', { method: 'GET' })
Creates a FetchMethod that retries failed requests according to the provided configuration.