From 085e92851bfe4689f7debc7864dc72dd2c220991 Mon Sep 17 00:00:00 2001 From: Adam Bouqdib Date: Wed, 29 Mar 2017 22:15:10 +0200 Subject: [PATCH] Fix error EUNKNOWN on 204 response All empty responses return a 500 EUNKNOWN error, the jsonapi spec however states that 204 responses are a valid response for POST, PATCH & DELETE requests where the result matches the request body. Here an excerpt from the spec on http://jsonapi.org/format/ ``` A server MUST return a 204 No Content status code if an update is successful and the representation of the resource in the request matches the result. ``` --- lib/Transport.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/Transport.js b/lib/Transport.js index 68de5d8..d386c4c 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -82,6 +82,10 @@ Transport.prototype._action = function(method, url, data, callback) { return callback(realErrors[0]); } + if (payload.statusCode == 204) { + return callback(null, payload.req, payload.req._data.data, payload.req._data.included); + } + if (!payload.body) { try { payload.body = JSON.parse(payload.text);