Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fetch-fetch-fetch

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fetch-fetch-fetch

Wraps netive fetch and allows for specifying timeout and retry.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
increased by600%
Maintainers
1
Weekly downloads
 
Created
Source

fetch-fetch-fetch

The Fetch API is a api that provides for interacting with network resources in a asynchronous manner. As of this writing, the native implementation is well supported in all browsers except IE. For full legacy support it is best to use a polyfill, such as whatwg-fetch.

This project wraps whatever version of the Fetch API you've chosen to use (native or polyfilled), and adds mechanisms that allow for specifying timeout length and retries.

Read this first

  • This library does not provide any implementation of the Fetch API and, as such, is not responsible for retrieving data. If you have found an error or bug in data retrieval, please open a bug with the relevant polyfill or browser team.

Installation

  • 'yarn add fetch-fetch-fetch'; or
  • 'npm install fetch-fetch-fetch --save'

Import the wrapper function:

import 'fetchFetchFetch' from 'fetch-fetch-fetch';

Usage

The first two parameters to the function are just the standard Fetch API parameters, consisting of the url and the init parameters, usage here.

Specifying a timeout length

A timeout length can be passed in milliseconds to the wrapper api. If a response is not received within the specified time period, the call is considered failed and an Error is thrown.

fetchFetchFetch('/my/data', undefined, 5000, undefined)
    .then(response => { console.log(response); })
    .catch(error => { console.log('Call failed'); });

Retrying failed calls

The wrapper api allows for specifying the number of times that the call should be tried. Retries will occur only if the call times out. A failure response from the service is considered a valid response and will be returned as normal.

fetchFetchFetch('/my/data', undefined, 5000, 2)
    .then(response => { console.log(response); });

Keywords

FAQs

Package last updated on 08 Apr 2018

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc