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

isomorphic-fetch-reject

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

isomorphic-fetch-reject

Isomorphic fetch that rejects on HTTP error

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-88.24%
Maintainers
1
Weekly downloads
 
Created
Source

isomorphic-fetch-reject

This package is using isomorphic-fetch and extends it to reject on HTTP error.

Standard fetch does not throw on HTTP errors (>= 400 status code). This wrapper allows it to do so.

This package is perfect for apps that render on both the server and the client side.

Install

npm i -S isomorphic-fetch-reject
yarn add isomorphic-fetch-reject

Usage

You can either use it like any other package:

import fetch from 'isomorphic-fetch-reject';

// Use just like the standard fetch
fetch('https://example.com/some/path')
  .then(res => res.json())
  .then(data => {
    console.log(data);
  })
  .catch(err => {
    console.error(err);
  });

Or you can add the fetch function directly to the global/window so you can use it from anywhere:

// file1.js
import fetch from 'isomorphic-fetch-reject';
fetch.replaceGlobal();
// file2.js
// Use just like the standard fetch
fetch('https://example.com/some/path')
  .then(res => res.json())
  .then(data => {
    console.log(data);
  })
  .catch(err => {
    console.error(err);
  });

FAQs

Package last updated on 05 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