Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

196
Vistas
using free national API to get data, "blocked by CORS policy" but works with postman/regular url

I am trying to get books list from National Library API (free for public use). It gives back JSON when visiting the URL in Chrome or hitting the endpoint with Postman. However, I can't get rid of the error when trying to make it through localhost, while developing. when I add: { mode: "no-cors"} to the fetch options, I get a response back, but opaque type, so I can't read the data.

fetch(
  `https://api.nli.org.il/openlibrary/search?api_key=uoX9ZMiaRMIBUF4pX0SEuGXMRpUqQIHrw5XuQKcE&query=title,exact,,AND;language,exact,heb&output_format=json&material_type=books`,
  {
    method: "GET",
    headers: {
      "Access-Control-Allow-Origin": "*",
    },
  }
).then((response) => console.log(response));

Error in console:

Access to fetch at 'https://api.nli.org.il/openlibrary/search?api_key=uoX9ZMiaRMIBUF4pX0SEuGXMRpUqQIHrw5XuQKcE&query=title,exact,%D7%97%D7%A0%D7%95%D7%9A,AND;language,exact,heb&output_format=json&material_type=books' from origin 'http://127.0.0.1:5500' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: 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.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda