New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

isomorphic-fetch-improve

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

isomorphic-fetch-improve

Improvements over isomorphic-fetch.

latest
Source
npmnpm
Version
1.3.0
Version published
Maintainers
1
Created
Source

isomorphic-fetch-improve

Improvements over isomorphic-fetch.

Installation

npm i isomorphic-fetch-improve -S

Usage

const fetch = require('isomorphic-fetch-improve')
const url = 'http://localhost:3000/test'

fetch(url, {
  timeout: 1000 * 30, // 30s
  retryDelay: 1000, // 1s
  retryMaxCount: 10,  // total 11 times request
  cancelableTaskName: 'task1',
  auth: {user: 'admin', password: 'secret'},  // basic auth
  method: 'get', // to upper case
  // forceMethod: 'PATCH', // case sensitive
  // ...
}).catch(err => {
  if (err.message == 'timeout') {
    // Request timeout
  } else if (err.message == 'cancel') {
    // This request was cancelled due to there is a new request
  } else {
    // Other
  }
})

// Send a request by the same task name again
fetch(url || null, {
  cancelableTaskName: 'task1',
})

Additional options

  • timeout [Default: 0] Set timeout.

  • retryMaxCount [Default: Infinity] Set retry max count, when an error occurred, such as refresh, lock screen.

  • retryDelay [Default: 0] Set delay milliseconds when retry.

  • cancelableTaskName [Default: null] Set the task name, to avoid the response data is replaced by old request in the response period.

  • auth [Default: null] Set user and password for basic authentication (Apply to relative paths).

  • forceMethod [Default: null] Set an original value to the request method.

License

MIT

Keywords

fetch

FAQs

Package last updated on 20 Feb 2019

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