approach to fixing #12

This commit is contained in:
tiagosiebler
2020-06-17 12:05:31 +01:00
parent 8a3ee76ba4
commit ccbba6dd38

View File

@@ -78,11 +78,18 @@ module.exports = class Request {
return new Promise((resolve, reject) => {
request(options, function callback(error, response, body) {
if(!error && response.statusCode == 200) {
resolve(body);
} else if(error) {
reject(error);
if (error) {
return reject(error);
}
if (response.statusCode == 200) {
return resolve(body);
}
return reject({
code: response.statusCode,
message: response.statusMessage,
body: response.body,
requestOptions: options
});
});
});
}