How do I await the forEach function so that I can console.log(posters)?
let posters = [];
reviews.forEach(async (review) => {
// Get posters for reviews
await axios.get(`https://api.themoviedb.org/3/movie/${review.filmId}?api_key=${tmdb_api}&language=en-US`)
.then((data) => {
posters.push(data.data.poster_path)
})
.catch((error) => console.log(error))
})
console.log(posters)
Important: I cannot put the console.log inside the .then() because I need the filled posters array outside of the forEach function.