Skip to content

Instantly share code, notes, and snippets.

@hperantunes
Last active June 20, 2019 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hperantunes/26e125910031a189dd6a87c13eaacc7a to your computer and use it in GitHub Desktop.
Save hperantunes/26e125910031a189dd6a87c13eaacc7a to your computer and use it in GitHub Desktop.
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