Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

fetch-retry

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fetch-retry

Fetch API with retry functionality

Source
npmnpm
Version
0.0.3
Version published
Maintainers
1
Created
Source

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(response => {
    return response.json()
  })
  .then(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

Keywords

fetch

FAQs

Package last updated on 27 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts