[英]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.