![](/img/trans.png)
[英]Axios response get 200 code status, but sometimes data is empty
[英]Get() with status code 200 caught in the exception
一个非常简单的get(),状态码为200时,它如何进入catch块?
const { promisify } = require('util');
const { get, post, patch, del } = require('https');
//const [ getPm, postPm, patchPm, deletePm ] = [get, post, patch, del].map(promisify);
const getPm = promisify(get);
(async () => {
try {
const res = await getPm('https://www.yahoo.com');
console.log('success !');
} catch (e) {
console.log('failure !');
console.log(e.statusCode);
}
})();
当我运行它时,打印出“失败”,状态为200,怎么来的? 有什么建议么 ?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.