Retry an async function until it succeeds or max attempts reached.
Async function to retry.
Maximum retry attempts.
Result of successful function.
const fn = async () => { if(Math.random()<0.5) throw new Error(); return 'ok'; };await retryAsync(fn, 3); Copy
const fn = async () => { if(Math.random()<0.5) throw new Error(); return 'ok'; };await retryAsync(fn, 3);
1.2.0
Retry an async function until it succeeds or max attempts reached.