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

node-fetch

Package Overview
Dependencies
Maintainers
2
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-fetch - npm Package Compare versions

Comparing version 1.6.3 to 1.7.0

lib/index.js

7

CHANGELOG.md

@@ -8,2 +8,9 @@

## v1.7.0
(Note: this is a maintenance release, `1.x` will only have backported bugfix beyond this release.)
- Fix: revert change in `v1.6.2` where 204 no-content response is handled with a special case, this conflicts with browser Fetch implementation (as browsers always throw when res.json() parses an empty string). Since this is an operational error, it's wrapped in a `FetchError` for easier error handling.
- Fix: move code coverage tool to codecov platform and update travis config
## v1.6.3

@@ -10,0 +17,0 @@

11

lib/body.js

@@ -42,9 +42,10 @@

// for 204 No Content response, buffer will be empty, parsing it will throw error
if (this.status === 204) {
return Body.Promise.resolve({});
}
var self = this;
return this._decode().then(function(buffer) {
return JSON.parse(buffer.toString());
try {
return JSON.parse(buffer.toString());
} catch (err) {
return Body.Promise.reject(new FetchError('invalid json response body at ' + self.url + ' reason: ' + err.message, 'invalid-json'));
}
});

@@ -51,0 +52,0 @@

{
"name": "node-fetch",
"version": "1.6.3",
"version": "1.7.0",
"description": "A light-weight module that brings window.fetch to node.js and io.js",

@@ -9,3 +9,3 @@ "main": "index.js",

"report": "istanbul cover _mocha -- -R spec test/test.js",
"coverage": "istanbul cover _mocha --report lcovonly -- -R spec test/test.js && cat ./coverage/lcov.info | coveralls"
"coverage": "istanbul cover _mocha --report lcovonly -- -R spec test/test.js && codecov"
},

@@ -31,3 +31,3 @@ "repository": {

"chai-as-promised": "^5.2.0",
"coveralls": "^2.11.2",
"codecov": "^1.0.1",
"form-data": ">=1.0.0",

@@ -34,0 +34,0 @@ "istanbul": "^0.4.2",

@@ -7,3 +7,3 @@

[![build status][travis-image]][travis-url]
[![coverage status][coveralls-image]][coveralls-url]
[![coverage status][codecov-image]][codecov-url]

@@ -210,3 +210,3 @@ A light-weight module that brings `window.fetch` to Node.js

[travis-url]: https://travis-ci.org/bitinn/node-fetch
[coveralls-image]: https://img.shields.io/coveralls/bitinn/node-fetch.svg?style=flat-square
[coveralls-url]: https://coveralls.io/r/bitinn/node-fetch
[codecov-image]: https://img.shields.io/codecov/c/github/bitinn/node-fetch.svg?style=flat-square
[codecov-url]: https://codecov.io/gh/bitinn/node-fetch

@@ -444,9 +444,6 @@

it('should return empty object on no-content response', function() {
it('should throw on no-content json response', function() {
url = base + '/no-content';
return fetch(url).then(function(res) {
return res.json().then(function(result) {
expect(result).to.be.an('object');
expect(result).to.be.empty;
});
return expect(res.json()).to.eventually.be.rejectedWith(FetchError);
});

@@ -453,0 +450,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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