No 'Access-Control-Allow-Origin' header is present on the requested Resource. API Codewars

Asked

Viewed 25 times

0

I was making a request on the Codewars API and had this problem. However, I don’t know how to fix it.

Access to XMLHttpRequest at 'https://www.codewars.com/api/v1/users/ThaysMrtns?access_key=DuNKdgzmE585M2e9CPJj' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.  
class UsuarioController{
    constructor(){

    }
    //Requisição de dados da API para o nosso usuário
    dadosUsuario(){
        let requisicao = new XMLHttpRequest();
        requisicao.open("GET", `https://www.codewars.com/api/v1/users/ThaysMrtns?access_key=DuNKdgzmE585M2e9CPJj`);
        requisicao.send();
        //let dados = requisicao.JSON.parse(requisicao.responseText);
        console.log(requisicao.responseText);
    }
}
  • 1

    You are having problems with CORS, learn more about: https://en.wikipedia.org/wiki/Cross-origin_resource_sharing#:~:text=Cross%2Dorigin%20resource%20%sharing 20(CORS,scripts%2C%20iframes%2C%20and videos.

  • Yes, thank you very much!

No answers

Browser other questions tagged

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