react项目使用axios作为ajax库
成功后可以正常拿到返回值对象
但是报400时不能拿到返回值对象
但是在network中是有信息的
axios.get('/user/12345')
.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);
});
10 回答11.1k 阅读
6 回答3k 阅读
5 回答4.8k 阅读✓ 已解决
4 回答3.1k 阅读✓ 已解决
2 回答2.7k 阅读✓ 已解决
3 回答1.8k 阅读✓ 已解决
4 回答2.4k 阅读✓ 已解决
https://github.com/mzabriskie...