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

167
Vistas
Why am I getting a "No 'Access-Control-Allow-Origin' header is present on the requested resource" error on my site?

I was messing around with API's to gain familiarity with them, and I'm trying to display a list of object names from an API. But when I open my website, nothing is displayed and I get a CORS error. Here is my code:

const url = 'https://api.wynncraft.com/v2/ingredient/list';
const mainDiv = document.getElementById('container');
fetch(url)
.then((resp) => resp.json())
.then(function(data) {
 let ingredients = data.results;
 return ingredients.map(function(ingredient) {
     let li = createNode('li');
     let span = createNode('span');
     span.innerHTML = `${ingredient.name}`;
     append(li, span);
     append(ul, li);
 })
})
.catch(function(error) {
 console.log(error);
});

function createNode(element) {
 return document.createElement(element);
}

function append(parent, el) {
 return parent.appendChild(el);
}

And the associated HTML:

<!DOCTYPE html>
<html>
    <head>
        <title>Wynncraft API Test</title>
    </head>
    <body>
        <div id="container"></div>
        <script src="script.js"></script>
    </body>
</html>

Any help is greatly appreciated!

Error Code

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