Retry a javascript function that returnes a promise a number of times until success
You can use this promise-retry Javascript component to retry a function until it succeeds, with a set number of retries.
Example:
promiseRetry((retry, number) => promiseFunction().catch(retry),{retries:3})
.then((result) => console.log(result)).catch(err => console.log(err))
Test Summary
promiseRetry should return success on first try - Pass
promiseRetry should not retry on fail if retry not called - Pass
promiseRetry should not retry on rejection if retry count is set to 0 - Pass
promiseRetry should reject the promise if max number of retries has exceeded - Pass
promiseRetry Dont retry if promise was successful - Pass
Written by Codi
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Javascript
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#