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!
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside