Skip to content
This repository has been archived by the owner on Jul 19, 2022. It is now read-only.

Commit

Permalink
Workaround for superagent issue setting body to null
Browse files Browse the repository at this point in the history
See more here: ladjs/superagent#638
  • Loading branch information
albertfdp committed May 4, 2015
1 parent 660fc67 commit 077a464
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,18 @@ module.exports = {
},

_onAuthResponse: function(callback, grantType, url, err, res) {
var responseData = res.body;

/*
* Handling superagent issue setting body to null, see more here:
* https://github.com/visionmedia/superagent/pull/638
*/
if (responseData === null) {
responseData = JSON.parse(res.text);
}

if (res.ok && !err) {
callback(null, res.body);
callback(null, responseData);
} else {
callback(new PodioErrors.PodioAuthorizationError('Authentication for ' + grantType + ' failed. Reason: ' + res.body.error_description, res.status, url), void 0);
}
Expand Down

0 comments on commit 077a464

Please sign in to comment.