JSPM

  • Created
  • Published
  • Downloads 3267409
  • Score
    100M100P100Q202636F
  • License MIT

Adds retry functionality to the Fetch API

Package Exports

  • fetch-retry

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (fetch-retry) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

fetch-retry

Adds retry functionality to the Fetch API.

It wraps isomorphic-fetch and retries requests that fail due to network issues.

Build Status

npm package

npm install fetch-retry --save

Example

fetch-retry works the same way as fetch, but also accepts retries and retryDelay on the options object. If omitted, they will default to 3 retries with a retry delay of 1000 ms.

var fetch = require('fetch-retry');
fetch(url, {
    retries: 3,
    retryDelay: 1000
  })
  .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