Vue axios configuration axios interceptor does not work

is there a problem with neither 504 nor 500 as shown in the following code?


error error

how can I get the status code of error?


switch case is used incorrectly, break is missing

case 500:
          loadinginstace.close();
          Message.error({
            message: ""
          });
break;

I have the same problem. I feel that axois's interceptor is not very easy to use, but Angular's interceptor is still powerful.
Update: you can get status in the following way

const status = err.toString().match(/\d{3}/)[0];

validateStatus: function (status) {
    return status >= 200 && status < 300; // default
},

because this is blocked, if you want to see all the http status, return true directly. You can get all the information in axios.interceptors.response.use 's callback , not an error callback.

Menu