The function to retry. It should return a value or a promise that resolves to a value.
The configuration options for retrying.
The result of the handler after it successfully completes.
// Basic retry with default options (2 retries, no delay)
const data = await retry(() => fetch('/api').then(r => r.json()));
// Retry with custom delays and max retries
const data = await retry(
() => fetch('/api').then(r => r.json()),
{ retries: 3, delay: [100, 500, 1000] }
);
Retry
handlerwhile it throws. Retries are based on the providedoptionswhich can define how many retries, delays between retries, and whether retries should continue based on the error.