我和这家伙也有同样的问题。'Can't get request a link with Axios due to No 'Access-Control-Allow-Origin' header is present on the requested resource‘。但奇怪的是,我可以通过Postman从这个端点获取数据,甚至可以从另一个项目获取数据。
axios.get('https://min-api.cryptocompare.com/data/all/coinlist')
.then(res => { // data
console.log(res.data) //console
})
.catch(function (error) { //errors
console.log(error);
});
const setAuthToken = token => {
if(token) {
axios.defaults.headers.common['Authorization'] = token;
} else {
delete axios.defaults.headers.common['Authorization']
}
};也许有一些解决方法。我使用node js作为后端,但仅用于注册和登录用户,我不认为这会有一些影响。但是我正在使用头来发出令牌请求,也许这就是问题所在?
发布于 2018-12-22 15:42:16
解决方案很简单。我只需要在请求前通过delete axios.defaults.headers.common"Authorization“清除报头
https://stackoverflow.com/questions/53890574
复制相似问题