JSPM

fetch-retry-or-die

0.0.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q38622F
  • License MIT

A wrapper around isomorphic-fetch that allows retries in case of request failure

Package Exports

  • fetch-retry-or-die

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-or-die) 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-or-die Circle CI

A wrapper around isomorphic-fetch that allows retries in case of request failure

Install

npm install [-S] fetch-retry-or-die

Usage

const fetch = require('fetch-retry-or-die');
let url = 'http://some.url'
fetch(url, {maxRetries: 5, retryDelay: 500})
  .then((response) => {
    // do something with the response
    ...
  });

Options

  • maxRetries: the maximum number of allowed retries. Defaults to 1.
  • retryDelay: the delay between retries in milliseconds. Defaults to 100.

Handles HTTP error statuses

  • Standard fetch functionality does not reject the promise on HTTP error status codes like 500.
  • fetch-retry-or-die rejects the promise if the status code is not 2XX or 404 (no need to retry if resource wasn't found, right?).