Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement