Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

174
Visualizações
Can't make a get request with header to an api

I'm trying to make a get request to an api,but there is en error: Failed to fetch, what might be wrong here?

const getData = () => {
  fetch("https://test-docs.stores.kg/api/categories", {
    method: "GET",
    headers: {
      secretKey: "test_key",
      accept: "application/json "
    }
  })
    .then((res) => res.json())
    .then((res) => console.log(res));
};

getData();

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Seems like the API you're querying is not setting a CORS header (check for reference https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS). Therefore your request is being blocked. cors_issue

If you are in control of this API adjust the webserver settings to set the appropriate header: e.g.

  • "Access-Control-Allow-Origin: https://YOUR_WEB_FRONTEND_DOMAIN.TLD"
  • (or if you just want to get it to work in a development setup) "Access-Control-Allow-Origin: *"

You can also test the API in this Tool here https://www.test-cors.org/#?client_method=GET&client_credentials=false&server_url=%20https%3A%2F%2Ftest-docs.stores.kg%2Fapi%2Fcategories&server_enable=true&server_status=200&server_credentials=false&server_tabs=remote

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda