/fetch-retry

Fetch API with retry functionality

Primary LanguageJavaScriptMIT LicenseMIT

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 is used the same way as fetch, but also accepts retries and retryDelay on the optional init object. When omitted these will default to 3 retries and a 1000ms retry delay.

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);
  });