您好!欢迎来到聚码网

聚码网

热门搜索: 相亲小程序    搭子源码    直播系统自有商城   
  • axios错误处理的对象error.response是空
  • 聚码交流
  • 0 2
  • yhuxAvNbtxUM
    0000-00-00 00:00:00
  • 回帖
_this.$http.post(`/company/${id}/out`,{access_token:_this.access_token,}).then((res)=>{letinfo=res;}).catch((err)=>{console.log(err.response);//err.response是undefined})},我想在403或者401的时候去处理这个错误,但是拿不到这个状态码。但是官网上就是这么用的。axios.get('/user/12345').catch(function(error){if(error.response){//Therequestwasmadeandtheserverrespondedwithastatuscode//thatfallsoutoftherangeof2xxconsole.log(error.response.data);console.log(error.response.status);console.log(error.response.headers);}elseif(error.request){//Therequestwasmadebutnoresponsewasreceived//`error.request`isaninstanceofXMLHttpRequestinthebrowserandaninstanceof//http.ClientRequestinnode.jsconsole.log(error.request);}else{//SomethinghappenedinsettinguptherequestthattriggeredanErrorconsole.log('Error',error.message);}console.log(error.config);});我的axios的版本是^0.16.1。
最近热帖
近期热议
联系我们
Q Q:317563994
电话:400-000-000
邮箱:317563994@qq.com
时间:09:00 - 17:00