[英]how to handle 500 error message with axios
I cannot get the response text in the 500 error
with axios.我无法使用 axios 获取
500 error
的响应文本。
in Network tab in dev tools i can find the error message like this在开发工具的网络选项卡中,我可以找到这样的错误消息
{"Message":"500 error message 0","Code":0,"Type":"error"}
and I use我用
axios()
.then(function(done) {
//fine and can get done.data
})
.catch(function(error) {
console.log(error.message);
});
but I can only get但我只能得到
Request failed with status code 500
so how can I get the response text with axios那么如何使用 axios 获取响应文本
according to axios readme :根据axios 自述文件:
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);
});
I cannot get the response text in the 500 error
with axios.我无法使用axios获得
500 error
的响应文本。
in Network tab in dev tools i can find the error message like this在开发工具的“网络”选项卡中,我可以找到这样的错误消息
{"Message":"500 error message 0","Code":0,"Type":"error"}
and I use我用
axios()
.then(function(done) {
//fine and can get done.data
})
.catch(function(error) {
console.log(error.message);
});
but I can only get但我只能得到
Request failed with status code 500
so how can I get the response text with axios所以我如何用axios获取响应文本
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.