Thanks Jason. That's my version based on your example:
const fetchWithRetry = (url) => { return new Promise((resolve, reject) => { let attempts = 1; const fetch_retry = (url, n) => { return fetch(url).then(resolve).catch(function (error) { if (n === 1) reject(error) else setTimeout(() => { attempts ++ fetch_retry(url, n - 1); }, attempts * 3000) }); } return fetch_retry(url, 5); }); }
Then I can call:
fetchWithRetry(api/data/${guid}).then(requestProcess)
api/data/${guid}
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks Jason. That's my version based on your example:
Then I can call:
fetchWithRetry(
api/data/${guid}
).then(requestProcess)