CORS error on request with Axios

Asked

Viewed 134 times

0

Okay, guys, I’m having a problem making a request with the Riot Games API. Response returns code 200, which is the code of when the request worked, but I cannot handle the object returned by json because of an error that is happening. NOTE: I’m a bit of a beginner in JS

Code: Let Axios = require('Axios')

axios.get('https://br1.api.riotgames.com/lol/summoner/v4/summoners/by-name/usuario?api_key=minhaApiKey')
.then(resposta => document.write(resposta.name))
.catch(error => console.log(error))

Erro que está aparecendo

  • You know how CORS works?

  • Another thing, in the image, you are showing the secret of your key to the API...

  • You are accessing an API with direct link, https://..., that is, it is not taking a path from your project, apparently this api does not allow to be used in this way, in this case, your current domain needs to be listing as permissive within the server of this api, for its return. This is done on the server side.

  • Behold if it helps you.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.