Skip to content

Solution/fetch-retry

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fetch-retry

Adds retry functionality to the Fetch API by wrapping isomorphic-fetch and retrying failing requests.

npm package

npm install fetch-retry --save

Example

fetch-retry works the same way as fetch, but also accepts a retries property on the options argument. If retries is not specified, it will default to using 3 retries.

var fetch = require('fetch-retry');
fetch(url, { retries: 5 })
  .then(function(response) {
    return response.json();
  })
  .then(function(json) {
    // do something with the result
    console.log(json);
  });

Caveats

The fetch specification differs from jQuery.ajax() in mainly two ways that bear keeping in mind:

  • The Promise returned from fetch() won't reject on HTTP error status even if the response is a HTTP 404 or 500. Instead, it will resolve normally, and it will only reject on network failure, or if anything prevented the request from completing.

Source: Github fetch

About

Fetch API with retry functionality

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • JavaScript 100.0%