Permalink
Browse files

Merge pull request #11 from glen-nicol/master

Handle long refresh token response
  • Loading branch information...
2 parents 56cae02 + f52fdb4 commit dd76dc687faf4c1381bdc502479ba1a6b3b8bbc7 @smurthas committed Apr 22, 2017
Showing with 7 additions and 3 deletions.
  1. +7 −3 gdata.js
View
@@ -17,14 +17,18 @@ function doPost(body, callback) {
var httpsReq = https.request(options, function (httpsRes) {
if (httpsRes.statusCode === 200) {
- httpsRes.on('data', function (data) {
+ var fullbody = "";
+ httpsRes.on('data', function (chunk) {
+ fullbody += chunk.toString();
+ });
+ httpsRes.on('end', function(){
var res;
try {
- res = JSON.parse(data.toString());
+ res = JSON.parse(fullbody.toString());
} catch(err) {
return callback({
err: err,
- res: data
+ res: fullbody
});
}
callback(null, res);

0 comments on commit dd76dc6

Please sign in to comment.