1

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.

0 Answers0