Answer the question
In order to leave comments, you need to log in
How to display values in index.html (node.js + express)?
Hey! I'm a beginner and now I'm trying to figure it out, please tell me what to do:
I'm trying to get data from the database and display it in a loop on the page.
app.get('/', function(req, res) {
connection.query("SELECT * FROM mini", function(err, rows) {
if(err) throw err;
res.render('index.html', { data: rows });
});
});
<div class="example"></div>
Answer the question
In order to leave comments, you need to log in
A method is a packaged (for convenience) something like this:res.render('file')
var jade = require('jade');
var htmlText = jade.renderFile('./file.jade', { ... });
res.send(htmlText);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question