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 - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

20

index.js
require('es6-promise').polyfill();
var fetch = require('isomorphic-fetch');
var fetchReject = require('fetch-reject');
var newFetch = fetchReject.createFetchReject(fetch);
function onResponse(res) {
if (res.ok) {
return res;
}
var error = new Error();
error.status = res.status;
error.response = res;
throw error;
}
function newFetch() {
return fetch.apply(this, arguments).then(onResponse);
}
module.exports = newFetch;
// So fetch stays consistent through the whole project
module.exports.replaceGlobal = () => {
module.exports.replaceGlobal = function() {
if (typeof global !== 'undefined') {

@@ -13,0 +23,0 @@ global.fetch = newFetch;

{
"name": "isomorphic-fetch-reject",
"version": "1.0.0",
"version": "1.0.1",
"description": "Isomorphic fetch that rejects on HTTP error",

@@ -10,10 +10,7 @@ "repository": "guestlinelabs/isomorphic-fetch-reject",

},
"files": [
"index.js"
],
"files": ["index.js"],
"dependencies": {
"es6-promise": "^4.2.4",
"fetch-reject": "^1.3.0",
"isomorphic-fetch": "^2.2.1"
}
}
# isomorphic-fetch-reject
This package is a mix of [isomorphic-fetch](https://www.npmjs.com/package/isomorphic-fetch) and [fetch-reject](https://www.npmjs.com/package/fetch-reject). It's isomorphic fetch request that rejects also on HTTP error.
This package is using [isomorphic-fetch](https://www.npmjs.com/package/isomorphic-fetch) and extends it to reject on HTTP error.
> Standard fetch does not throw on HTTP errors (non-200 status code). This wrapper allows it to do so.
> 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 the server side as well as on the client side.
This package is perfect for apps that render on both the server and the client side.

@@ -9,0 +9,0 @@ ## Install

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