axios returns an error message

After the browser interface request fails, the data
Insert picture description here
browser prints the result

Insert picture description here

Solution

axios.get('/user/id')
  .catch(function (error) {
    
    
    if (error.response) {
    
    
      // 请求已发出,但服务器响应的状态码不在 2xx 范围内
      console.log(error.response.data);
      console.log(error.response.status);
      console.log(error.response.headers);
    } else {
    
    
      // Something happened in setting up the request that triggered an Error
      console.log('Error', error.message);
    }
    console.log(error.config);
  });

Quick Portal: https://github.com/axios/axios#handling-errors

Guess you like

Origin blog.csdn.net/super__code/article/details/106558218