javascript - axios error handling object error.response is empty
女神的闺蜜爱上我
女神的闺蜜爱上我 2017-06-24 09:44:10
0
1
1609
_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
})
},

I want to handle this error when it is 403 or 401, but I cannot get this status code. But this is how it is used on the official website.

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);
  });

My axios version is ^0.16.1.

女神的闺蜜爱上我
女神的闺蜜爱上我

reply all(1)
给我你的怀抱

403 is not clear, but I remember the answer I checked before was that 401 will be intercepted and processed by the browser, and js cannot be obtained

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template