A promise that resolves to a RetryResult.
The function will be called retries + 1
times.
The result can can also be checked with the helper isRetryOK.
// if the fetch fails, retry 3 times with a 1 second interval
const result = await retry(
() => fetch('https://example.com'),
3,
1000
)
if ('ok' in result) {
console.log(result.ok)
} else {
console.error(result.err)
}
// or
import { isRetryOK } from 'uft'
if (isRetryOK(result)) {
console.log(result.ok)
} else {
console.error(result.err)
}
Generated using TypeDoc
Continuously retries a given function until it succeeds or the number of retries is exceeded.