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);
}
}
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.
– Rebeca Nonato
Yes, thank you very much!
– Thays Martins