Created
May 19, 2017 08:46
-
-
Save pietmichal/fc76362cbca520aa9c5b0a4dd2c8dce0 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
| function retryablePromise(retries) { | |
| return new Promise((resolve, reject) => { | |
| reject(); | |
| }) | |
| .catch(() => { | |
| if (retries > 0) { | |
| return retryablePromise(retries - 1); | |
| } else { | |
| return Promise.reject(); | |
| } | |
| }); | |
| } | |
| retryablePromise(5) | |
| .then(() => { | |
| console.log('resolved!'); | |
| }) | |
| .catch(() => { | |
| console.log('all attempts failed'); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment