Skip to content

Instantly share code, notes, and snippets.

@slonoed
Forked from mordaha/testEpic.js
Last active Sep 21, 2017
Embed
What would you like to do?
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