Created
January 20, 2024 22:05
-
-
Save gleydson/ac0d0150c598321491af725742531479 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function retry<T>(fn: () => Promise<T>, retries: number = 5) { | |
try { | |
return await retry() | |
} catch (err) { | |
if (retries > 0) { | |
console.log("Retrying...") | |
return await retry(fn, retries - 1) | |
} | |
throw err | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment