-
-
Save slonoed/001b4c7033b518caa0695447e05094be 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(foo, count = 1, delay) { | |
let error; | |
while (count--) { | |
try { | |
return foo() | |
} catch (e) { | |
error = e | |
await timeout(delay) | |
} | |
} | |
throw error | |
} | |
async function testEpic() { | |
try { | |
const foo = () => fetch('/1234') | |
const data = retry(foo, 3, 3000) | |
dispatch(data) | |
} catch (e) { | |
dispatch(e) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment