Now this method throws an error if the response code is not 2xx (learned experimentally)
const request = require('request-promise-native');
(async () => {
try {
const response = await request({
uri: 'http://httpbin.org/status/201',
resolveWithFullResponse: true,
});
console.log(response.statusCode); // we here
} catch (error) {
console.error(error); // i want to be here if statusCode !== 200
}
})();
Maybe there is some parameter or another package that can do something i want?
how about this