Skip to content

Commit

Permalink
Revert "Return empty .json() object on 204. Fix #165. (#166)" (#201)
Browse files Browse the repository at this point in the history
This reverts commit 95b5893.

Fixes #165.
  • Loading branch information
TimothyGu committed Nov 26, 2016
1 parent 7f0e502 commit d3071fa
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 15 deletions.
5 changes: 0 additions & 5 deletions src/body.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ export default class Body {
* @return Promise
*/
json() {
// for 204 No Content response, buffer will be empty, parsing it will throw error
if (this.status === 204) {
return Body.Promise.resolve({});
}

return this[CONSUME_BODY]().then(buffer => JSON.parse(buffer.toString()));
}

Expand Down
10 changes: 0 additions & 10 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,16 +471,6 @@ describe(`node-fetch with FOLLOW_SPEC = ${defaultFollowSpec}`, () => {
});
});

it('should return empty object on no-content response', function() {
url = `${base}no-content`;
return fetch(url).then(res => {
return res.json().then(result => {
expect(result).to.be.an('object');
expect(result).to.be.empty;
});
});
});

it('should handle no content response with gzip encoding', function() {
url = `${base}no-content/gzip`;
return fetch(url).then(res => {
Expand Down

0 comments on commit d3071fa

Please sign in to comment.