Olá,
Como eu posso utilizar o método .setRequestHeader()? Pois estou fazendo uma requisição em uma URL que me retorna o seguinte erro:
XMLHttpRequest cannot load https://api.cartolafc.globo.com/partidas. The 'Access-Control-Allow-Origin' header has a value 'https://cartolafc.globo.com' that is not equal to the supplied origin. Origin 'null' is therefore not allowed access.
Segue meu código JS:
var xhr = new XMLHttpRequest();
  xhr.open("GET", "https://api.cartolafc.globo.com/partidas");
  // xhr.setRequestHeader("Access-Control-Allow-Origin", "*"); O que fazer aqui?
  xhr.addEventListener("load", function(){
    if (xhr.status == 200) {
      var resposta = xhr.responseText;
      console.log(resposta);
      console.log(typeof resposta);
      var pacientes = JSON.parse(resposta);
      console.log(pacientes);
      console.log(typeof pacientes);
    } else {
      console.log(xhr.status);
      console.log(xhr.responseText);
    }
  });
  xhr.send();
Obrigado