Created
June 8, 2021 14:12
-
-
Save vilmid/577858bdb62d7b5c22ba1e65c7bc72da 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
| /** | |
| * @param {string} url | |
| * @param {Object} options | |
| * @param {Number} attempt | |
| * @returns {Promise<Response>} | |
| */ | |
| const fetchWithRetry = async (url, options, attempt) => { | |
| try { | |
| return await fetch(url, options) | |
| } catch (err) { | |
| if (attempt === 1) throw err | |
| return await fetchWithRetry(url, options, attempt - 1) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment