Retries an async function with exponential backoff. Useful for handling transient failures in network requests, etc.
Throws an Error when retry(config) is called with a maxAttempts below 1 or NaN, or a NaN or negative initialDelayMs, backoffMultiplier or maxDelayMs.
Error
retry(config)
maxAttempts
NaN
initialDelayMs
backoffMultiplier
maxDelayMs
const fetchWithRetry = retry({ maxAttempts: 3 })(fetchData);const data = await fetchWithRetry(); Copy
const fetchWithRetry = retry({ maxAttempts: 3 })(fetchData);const data = await fetchWithRetry();
Retry configuration
Wrapped function that retries on failure
Retries an async function with exponential backoff. Useful for handling transient failures in network requests, etc.
Throws an
Errorwhenretry(config)is called with amaxAttemptsbelow 1 orNaN, or aNaNor negativeinitialDelayMs,backoffMultiplierormaxDelayMs.Example