handlebars.js

How to display MySQL “result” object to user with express-handlebars?

核能气质少年 提交于 2020-08-12 01:44:31
问题 I currently have a query in my node js that looks like this: app.get('/fav/books', function(req, res){ var sql = ("SELECT title, pictureUrl, author, description, genre FROM books") connection.query(sql, function(err, result){ if(err) { console.log('Error in the query.'); } else { console.log('Success!\n'); console.log(result); var book = result; return book; } }); }); And outputs to console like this: Console Output I want to "return book;" to the user with handlebars in a sort of card output

How to display MySQL “result” object to user with express-handlebars?

我是研究僧i 提交于 2020-08-12 01:41:26
问题 I currently have a query in my node js that looks like this: app.get('/fav/books', function(req, res){ var sql = ("SELECT title, pictureUrl, author, description, genre FROM books") connection.query(sql, function(err, result){ if(err) { console.log('Error in the query.'); } else { console.log('Success!\n'); console.log(result); var book = result; return book; } }); }); And outputs to console like this: Console Output I want to "return book;" to the user with handlebars in a sort of card output