【发布时间】:2018-02-09 08:01:30
【问题描述】:
这是我第一次使用axios,遇到了一个错误。
axios.get(
`http://someurl.com/page1?param1=1¶m2=${param2_id}`
)
.then(function(response) {
alert();
})
.catch(function(error) {
console.log(error);
});
使用正确的 url 和参数,当我检查网络请求时,我确实从我的服务器得到了正确的答案,但是当我打开控制台时,我发现它没有调用回调,而是发现了一个错误。
错误:网络错误 堆栈跟踪: createError@http://localhost:3000/static/js/bundle.js:2188:15 处理错误@http://localhost:3000/static/js/bundle.js:1717:14
【问题讨论】:
-
您可以使用
console.log(error.response.data)了解更多信息。 -
查看这个答案,它将帮助您了解错误到底是什么stackoverflow.com/questions/44806333/…
-
@FaustoNA error.response 未定义
-
@ShubhamKhatri 显然 CORS 是问题
-
太好了,你能弄明白。但是请按照我发布的链接中提到的使用 axios 处理错误
标签: javascript reactjs axios