node-fetch
Advanced tools
+7
-2
@@ -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 |
+5
-0
@@ -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()); |
+1
-1
| { | ||
| "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", |
+9
-0
@@ -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 |
+15
-5
@@ -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() { |
Network access
Supply chain riskThis module accesses the network.
Found 3 instances in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 3 instances in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
84031
0.96%2310
0.57%211
4.46%129
0.78%