Last active
June 20, 2019 14:35
-
-
Save hperantunes/26e125910031a189dd6a87c13eaacc7a to your computer and use it in GitHub Desktop.
This file contains 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
import retry from "async-retry"; | |
const retryOptions = { | |
forever: true, | |
factor: 2 | |
}; | |
export default (url, options) => retry(async () => { | |
const response = await fetch(url, options); | |
if (response.status !== 200) { | |
throw new Error(response.status); | |
} | |
return response.json(); | |
}, retryOptions); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment