Retry a function with exponential backoff.
Return type of the function.
Async function to retry.
Maximum number of attempts (default 3).
3
Base delay between retries in ms (default 500). Doubles each attempt.
500
The result of the first successful invocation.
The last error if all attempts fail.
1.0.0
const data = await retry(() => fetch('/api'), 5, 1000); Copy
const data = await retry(() => fetch('/api'), 5, 1000);
Retry a function with exponential backoff.