我遇到的一个问题是,当我键入**console.log(response.data)
**时,它应该向我显示一个包含许多数组的对象,但是它的位置显示了一个错误:Uncaught (承诺) =>,我在控制台中得到了这个错误
知道我的API中没有错误,因为当我在postman中尝试它时,它会带来正确的参数。
这是我的密码:
const baseUrl = "https://....";
function getStandings() {
const url = `${baseUrl}/standings`
axios.get(url, {
headers: {
"X-Auth-Token": `${token}`
}
})
.then((response) => {
console.log(response.data)
});
}
getStandings();
⚠注意到:token
和baseUrl
--它们是正确的。
它进入错误,我将其记录到控制台。我得到的是:
message: 'Network Error', name: 'AxiosError', code: 'ERR_NETWORK', config: {…}, request: XMLHttpRequest, …
发布于 2022-11-18 21:08:01
我找到了解决方案,唯一的问题是我必须从一个不支持CORS
的浏览器中输入,以向我展示API的结果。
这个网站帮了我很多=> 运行没有CORS的Chrome浏览器
https://stackoverflow.com/questions/74478135
复制相似问题