Reputation: 1010
I am trying to use the cryptocompare api to get a list of coindata with axios but I can't figure out how to get around this issue I believe it's a CORS issue, but I am not sure.
The full error is as follows: Failed to load https://www.cryptocompare.com/api/data/coinlist/: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. The response had HTTP status code 524.
I am using axios with the following code:
addCoinData(coinData) {
axios.get('https://www.cryptocompare.com/api/data/coinlist/')
.then(res => {
const crypto = res.data;
this.setState({crypto: crypto});
})
.catch(function (error) {
console.log(error);
});
console.log(this.state.crypto);
};
Upvotes: 2
Views: 1292
Reputation: 146
Their API just changed the url for the data that you want to get.
https://min-api.cryptocompare.com/data/all/coinlist
I've successfully made a GET request test with this url with axios as well.
axios.get('https://min-api.cryptocompare.com/data/all/coinlist')
.then(res => {
console.log(res.data)
})
.catch(function (error) {
console.log(error);
});
I hope it helps.
Upvotes: 3