Skip to content

Commit

Permalink
Merge pull request #694 from sulaysumaria/master
Browse files Browse the repository at this point in the history
Accept content type json with empty body
  • Loading branch information
dherault committed Jun 7, 2019
2 parents 0aed504 + c250a2c commit bd65e02
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/index.js
Expand Up @@ -594,6 +594,10 @@ class Offline {
const contentTypesThatRequirePayloadParsing = ['application/json', 'application/vnd.api+json'];
if (contentTypesThatRequirePayloadParsing.includes(contentType) && request.payload && request.payload.length > 1) {
try {
if (!request.payload || request.payload.length < 1) {
request.payload = '{}';
}

request.payload = JSON.parse(request.payload);
}
catch (err) {
Expand Down

0 comments on commit bd65e02

Please sign in to comment.