javascript - axios錯(cuò)誤處理的對(duì)象error.response 是空
問題描述
_this.$http.post(`/company/${id}/out`, { access_token: _this.access_token,}).then((res) => { let info = res;}).catch((err) => { console.log(err.response); // err.response 是 undefined})},

我想在 403 或者 401 的時(shí)候去處理這個(gè)錯(cuò)誤,但是拿不到這個(gè)狀態(tài)碼。但是官網(wǎng)上就是這么用的。
axios.get(’/user/12345’) .catch(function (error) { if (error.response) { // The request was made and the server responded with a status code // that falls out of the range of 2xx console.log(error.response.data); console.log(error.response.status); console.log(error.response.headers); } else if (error.request) { // The request was made but no response was received // `error.request` is an instance of XMLHttpRequest in the browser and an instance of // http.ClientRequest in node.js console.log(error.request); } else { // Something happened in setting up the request that triggered an Error console.log(’Error’, error.message); } console.log(error.config); });
我的axios 的版本是 ^0.16.1。
問題解答
回答1:403不清楚,但是我記得之前我查的答案是401會(huì)被瀏覽器攔截處理掉,js拿不到
相關(guān)文章:
1. 我在centos容器里安裝docker,也就是在容器里安裝容器,報(bào)錯(cuò)了?2. 在windows下安裝docker Toolbox 啟動(dòng)Docker Quickstart Terminal 失敗!3. docker-compose中volumes的問題4. docker不顯示端口映射呢?5. golang - 用IDE看docker源碼時(shí)的小問題6. docker內(nèi)創(chuàng)建jenkins訪問另一個(gè)容器下的服務(wù)器問題7. 關(guān)docker hub上有些鏡像的tag被標(biāo)記““This image has vulnerabilities””8. javascript - 最近用echarts做統(tǒng)計(jì)圖時(shí)遇到兩個(gè)問題!!9. javascript - 連續(xù)點(diǎn)擊觸發(fā)mouseleave事件10. mac里的docker如何命令行開啟呢?

網(wǎng)公網(wǎng)安備