![](/img/trans.png)
[英]Axios. How to get error response even when api return 404 error, in try catch finally
[英]Why Axios logs error 403 even when I catch it
基於axios文檔,我的請求后有catch塊,但是即使我捕獲了錯誤並顯示了Alert,在瀏覽器控制台上我也收到消息:
POST http://localhost:5000 403 (Forbidden) spread.js:25
為什么上面有消息? 這是默認的瀏覽器行為嗎?
客戶:
axios.get('/user?ID=12345')
.then(function (response) {
console.log(response);
})
.catch(function (error) {
alert(error);
});
服務器:
res.status(403).send('Error message');
是的,至少默認情況下,Chrome瀏覽器會記錄每個失敗的http請求。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.