I have this app that allows users to review movies, and I'm trying to add a feature that grabs the poster from the movie and displays it next to the review. I tried to do this using
query database and return list of movies => imdb-id to get the IMDB ID => imdb to get the poster url => add that to a variable and compile with pug
However, I can't get it to work as the array always returns empty first before anything else runs. I've tried to use async waterfall, but I can't figure out how to loop through the array that is returned, and pass the ID to get the url
async.waterfall([
function (callback) {
console.log('Request Id:', username);
var query = "SELECT title, rating, review FROM movies WHERE username = \"" + username + "\" ORDER BY title;";
callback(null, query);
}, function (query, callback) {
// Run query on db
connection.query(query, callback);
}, function (rows, fields, cb) {
// Get array of titles
var rowArray = rows;
console.log(rowArray);
}
],
function(err) {
// error stuff
})