0

The following code throws this error:

var config = {
    method: 'get',
    url: `https://euw1.api.riotgames.com/lol/summoner/v4/summoners/by-name/${encodeURI(name)}?api_key=${this.apiKey}`,
    headers: {}
};

axios(config)
    .then(function (response) {
        console.log(JSON.stringify(response.data));
    })
    .catch(function (error) {
        console.log(error);
    });

The request in itself works but I dont know to fix this problem.

Stack from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Tiago Martins Peres
  • 14,289
  • 18
  • 86
  • 145
Pascal
  • 66
  • 6
  • Are you using express? If yes, you need to set the set the CORS headers. – danibrum Nov 22 '20 at 19:32
  • Does this answer your question? [Axios having CORS issue](https://stackoverflow.com/questions/50949594/axios-having-cors-issue) – falinsky Nov 22 '20 at 19:36

0 Answers0