Socket
Socket
Sign inDemoInstall

node-fetch

Package Overview
Dependencies
4
Maintainers
1
Versions
96
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.6.1 to 1.6.2

9

CHANGELOG.md

@@ -8,4 +8,9 @@

## v1.6.1 (master)
## v1.6.2
- Enhance: minor document update
- Fix: response.json() returns empty object on 204 no-content response instead of throwing a syntax error
## v1.6.1
- Fix: if `res.body` is a non-stream non-formdata object, we will call `body.toString` and send it as a string

@@ -26,3 +31,3 @@ - Fix: `counter` value is incorrectly set to `follow` value when wrapping Request instance

- Fix: handles 204 and 304 responses when body is empty but content-encoding is gzip/deflate
- Fix: handle 204 and 304 responses when body is empty but content-encoding is gzip/deflate
- Fix: allow resolving response and cloned response in any order

@@ -29,0 +34,0 @@ - Fix: avoid setting `content-length` when `form-data` body use streams

@@ -42,2 +42,7 @@

// for 204 No Content response, buffer will be empty, parsing it will throw error
if (this.status === 204) {
return Body.Promise.resolve({});
}
return this._decode().then(function(buffer) {

@@ -44,0 +49,0 @@ return JSON.parse(buffer.toString());

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

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -67,2 +67,11 @@

// catching network error
// 3xx-5xx responses are NOT network errors, and should be handled in then()
// you only need one catch() at the end of your promise chain
fetch('http://domain.invalid/')
.catch(function(err) {
console.log(err);
});
// stream

@@ -69,0 +78,0 @@ // the node.js way is to use stream when possible

@@ -444,2 +444,12 @@

it('should return empty object on no-content 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;
});
});
});
it('should handle no content response with gzip encoding', function() {

@@ -1384,3 +1394,3 @@ url = base + '/no-content/gzip';

});
});

});

@@ -1396,3 +1406,3 @@ it('should support json() method in Request constructor', function() {

});
});

});

@@ -1408,3 +1418,3 @@ it('should support buffer() method in Request constructor', function() {

});
});

});

@@ -1456,3 +1466,3 @@ it('should support arbitrary url in Request constructor', function() {

expect(body).to.have.property('buffer');
});

});

@@ -1471,3 +1481,3 @@ it('should create custom FetchError', function() {

expect(err.errno).to.equal('ESOMEERROR');
});

});

@@ -1474,0 +1484,0 @@ it('should support https request', function() {

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc