diff --git a/lib/openpay.js b/lib/openpay.js index 935afef..58cd68f 100644 --- a/lib/openpay.js +++ b/lib/openpay.js @@ -789,14 +789,12 @@ var sendRequest = function (data) { json: true, timeout: data.timeout }; - //console.log(data.apiUrl); //console.log(_.extend(baseRequestOptions, data.requestData)); var data = _.extend({}, data); request(_.extend(baseRequestOptions, data.requestData), function(err, res, body){ - var resCode = res.statusCode; - var error = (resCode!=200 && resCode!=201 && resCode!=204) ? body : null; - data.callback(error, error ? null : body, res); + var resCode = res ? res.statusCode : null; + var error = resCode && (resCode!=200 && resCode!=201 && resCode!=204) ? body : null; + data.callback(err ? err : error, err || error ? null : body, res); }); } -//request('http://www.google.com', function (error, response, body) {}) module.exports = Openpay;