Last Updated: June 01, 2017
·
3.259K
· Codi

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