mirror of
https://github.com/HackPlan/node-iap.git
synced 2026-06-14 17:09:15 +08:00
finished implementation of code to follow documentation. Also made fixes as per pr comments
This commit is contained in:
@@ -10,14 +10,12 @@ module.exports = function (url, options, cb) {
|
||||
try {
|
||||
if (options.form) {
|
||||
data = formUrlencoded.encode(options.form);
|
||||
delete options.form;
|
||||
options.headers = {
|
||||
'content-type': 'application/x-www-form-urlencoded',
|
||||
'content-length': Buffer.byteLength(data)
|
||||
};
|
||||
} else if (data.json) {
|
||||
data = JSON.stringify(data.json);
|
||||
delete options.json;
|
||||
options.headers = {
|
||||
'content-type': 'application/json',
|
||||
'content-length': Buffer.byteLength(data)
|
||||
|
||||
@@ -29,11 +29,7 @@ module.exports = function (requestUrl, options, data, cb) {
|
||||
});
|
||||
|
||||
res.on('end', function () {
|
||||
if (res.statusCode !== 200) {
|
||||
return cb(new Error('Received ' + res.statusCode + ' status code with body: ' + responseData));
|
||||
}
|
||||
|
||||
cb(null, responseData);
|
||||
cb(null, res, responseData);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user