Hello the following code is working. However, I was wondering if there is a way to not repeat the function findMovie in the array which is asynchronous multiple times as I'm currently doing.
var request = require('request-promise');
function findMovie(title){
return request(`http://www.omdbapi.com/?t=${title}`)
.then(res=>{
var movie= JSON.parse(res)
return [movie["Title"], movie["Year"],movie["Genre"]]
})
}
function loadInitialData(movies){
return Promise.all(movies)
.then((response)=>{
response.forEach((movie)=>{
console.log(movie[0])
})
})
}
var movies= [findMovie("jason bourne"), findMovie("The Matrix"), findMovie("titanic")];
// Above is the function findMovie being written multiple times to make it work...
loadInitialData(movies);