Skip to content

Commit

Permalink
Merge pull request #290 from etduroch/master
Browse files Browse the repository at this point in the history
Invalid json empty body error fix
  • Loading branch information
DavidZey committed Aug 18, 2014

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents d5c04bf + c826ea4 commit 6d745f2
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/feather-client/restProxy.js
Original file line number Diff line number Diff line change
@@ -40,13 +40,14 @@
}
}

var requestData = (typeof options.data === "undefined" || options.data === null) ? null : JSON.stringify(options.data);
$.ajax({
url: encodeURI("/_rest/" + api.name + decodeURI(options.path)),
data: (typeof options.data === "undefined" || options.data === null) ? null : JSON.stringify(options.data),
data: requestData,
type: method.verb,
dataType: "json",
headers: options.headers || null,
contentType: contentType,
contentType: requestData ? contentType : null, // don't set contentType if no data, bodyParser will throw exception.
success: function(result) {
cb && cb({
success: true,
2 changes: 1 addition & 1 deletion lib/middleware.js
Original file line number Diff line number Diff line change
@@ -262,7 +262,7 @@ exports.getMiddleware = function(options, cb) {
if (err.message == _404error) {
logger.error({category: '404', message: 'Request for non-existent resource: ' + req.originalUrl});
} else {
logger.error({category: 'uncaught', message: 'Uncaught Exception in request middleware stack --- Stacktrace:', exception: err});
logger.error({category: 'uncaught', message: 'Uncaught Exception in request middleware stack --- URL: ' + (req ? req.originalUrl : '') + ', Stacktrace:', exception: err});
}
next(err);
}

0 comments on commit 6d745f2

Please sign in to comment.