Skip to content

Commit

Permalink
Merge pull request #10 from Jalepeno112/master
Browse files Browse the repository at this point in the history
Fixed `call()` function to chunk incoming data
  • Loading branch information
vasusen committed Jul 15, 2016
2 parents 4749401 + 39f3aea commit e945f25
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/wepay.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,17 @@ exports.WEPAY = function(settings)
}

var request = http.request(options, function(response) {
// setup a variable to hold all of the response info.
// it's possible that the response is too larger for NodeJS to handle in a single request
// this will appropriately chunk the incoming response so that we receive all of the info
var body = "";
response.on('data', function(chunk) {
// get the last argument
body += chunk;
});
response.on("end", function() {
// check the callbackFunction and return the data we received
if (callbackFunction && typeof callbackFunction === 'function') {
callbackFunction(chunk);
callbackFunction(body);
}
});
});
Expand Down

0 comments on commit e945f25

Please sign in to comment.