1 回答

TA貢獻(xiàn)1891條經(jīng)驗(yàn) 獲得超3個(gè)贊
根據(jù) axios處理錯(cuò)誤,底層錯(cuò)誤數(shù)據(jù)message
應(yīng)在以下位置提供error.response.data
:
.catch((error) => {
? token = null
? console.log('error =>', error.response.data)
});
您可能想要使用該示例并處理可能發(fā)生的不同類(lèi)型的錯(cuò)誤:
.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);
});
希望這有幫助!
添加回答
舉報(bào)