我正在一个脚本来从我的API的一些数据:赶上()不处理404
const success = (response) => {
console.log(response);
};
const failed = (error) => {
console.log(error);
};
axios.$http.get('/somedata')
.then((response) => {
success(response.data);
})
.catch((error) => {
failed(error);
});
/somepage
是不存在的页面,以便它返回一个404,但美中不足的是没有处理这个。为什么不?在我的控制台中,我有错误TypeError: Cannot read property 'data' of undefined
。为什么它不运行failed()
函数?我不明白。
的可能的复制[承诺:再VS那么+抓(http://stackoverflow.com/questions/33278280/promise-then-vs-then-catch) – CMedina
您使用的是什么版本的爱可信? – roger
最新版本:0.15.2 – Jordy