2
votes

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);
};
1

1 Answers

3
votes

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.