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

142
Vistas
How do I store output from JSON fetch in a variable (Javascript)?

Trying to get these Genres and save them into an array called genres that can be used with dom and react. How do I do this? Right now all I can do is console.log them.

const genres = [""];
const options = {
    method: 'GET',
    headers: {
        'X-RapidAPI-Key': '8a7d386af8msh99bcb7b70a0270ep1d0017jsn4f50689ce12a',
        'X-RapidAPI-Host': 'moviesdatabase.p.rapidapi.com'
    }
};

fetch('https://moviesdatabase.p.rapidapi.com/titles/utils/genres', options)
    .then(response => response.json())
    .then(d => {for(let a of d.results){
      if(a != null){
        genres.push(JSON.stringify(a));
        console.log(a);
      }
  }})
    .catch(err => console.error(err));
  console.log(genres);```

Any help would be appreciated. Let me know if you need anymore info as to what I am doing.
about 4 years ago · Santiago Trujillo
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