1 回答
TA贡献1891条经验 获得超3个赞
根据 axios处理错误,底层错误数据message
应在以下位置提供error.response.data
:
.catch((error) => {
token = null
console.log('error =>', error.response.data)
});
您可能想要使用该示例并处理可能发生的不同类型的错误:
.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);
});
希望这有帮助!
添加回答
举报