request does not always have an err object when res.status !== 200
Using getInfo.js as an example:
request(requestConfigs, function(err, res, body) {
if (!err && res.statusCode == 200) {
resolve(JSON.parse(body));
} else if (err) {
reject(err);
}
});
When calling this method with a listing ID that does not exist Airbnb return status = 404 with the body = {error_code:404, error: 'record_not_fond' ...} but err object in null.
Because of your "if else" statement neither resolve or reject is called... which is bad as this hangs and never returns.
Propose a change to something like:
request(requestConfigs, function(err, res, body) {
if (res.statusCode == 200) {
resolve(JSON.parse(body));
} else {
reject(JSON.parse(body));
}
});
requestdoes not always have anerrobject whenres.status !== 200Using
getInfo.jsas an example:When calling this method with a listing ID that does not exist Airbnb return
status = 404with thebody = {error_code:404, error: 'record_not_fond' ...}buterrobject innull.Because of your "if else" statement neither
resolveorrejectis called... which is bad as this hangs and never returns.Propose a change to something like: