Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

150
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!