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

305
Visualizações
Fetch Api Call to a External Api results in CORS Error, But in Browser it works fine

I am trying to make a fetch call to a web server via apis.

var requestOptions = {
  method: 'GET',
  redirect: 'follow'
};

fetch(
  "https://api-mainnet.magiceden.dev/v2/collections?offset=0&limit=3",
  requestOptions
)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.log("error", error));

This seems to throw this error enter image description here

Access to fetch at 'https://api-mainnet.magiceden.dev/v2/collections?offset=0&limit=3' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

But the same url if I try to access in the browser . Displays the data. enter image description here Any help on how I can get the fetch api call to work would be much appreciated.

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

0

What Are your "requestOptions"? I've tried this, and it's working fine.

fetch("https://api-mainnet.magiceden.dev/v2/collections?offset=0&limit=3" )
            .then((response) => response.text())
            .then((result) => console.log(result))
            .catch((error) => console.log("error", error));
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