Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. async function retry(foo, count = 1, delay) {
  2. let error;
  3. while (count--) {
  4. try {
  5. return foo()
  6. } catch (e) {
  7. error = e
  8. await timeout(delay)
  9. }
  10. }
  11. throw error
  12. }
  13.  
  14. async function testEpic() {
  15. try {
  16. const foo = () => fetch('/1234')
  17. const data = retry(foo, 3, 3000)
  18. dispatch(data)
  19. } catch (e) {
  20. dispatch(e)
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement