Skip to content

Commit

Permalink
204 No Content revision (#16)
Browse files Browse the repository at this point in the history
* fix(fetchUtils): 204 should ignore content regardless of headers

* linting
  • Loading branch information
runruh committed Feb 14, 2020
1 parent 3b41830 commit dfc7457
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/fetchUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ handlers.finish = function (response, data) {
* @returns {Promise} promise
*/
handlers.decode = function (response) {
// No content, ignore response and return success
if (response.status === 204) {
return handlers.finish(response, null);
}

const contentType = response.headers.get('content-type');

if (!contentType && response.status === 204) {
return handlers.finish(response, null);
} else if (contentType.includes('application/json')) {
if (contentType.includes('application/json')) {
return response.json()
.then(data => handlers.finish(response, data));
}
Expand Down

0 comments on commit dfc7457

Please sign in to comment.