E
E
Erik21212017-06-13 09:56:13
Node.js
Erik2121, 2017-06-13 09:56:13

How to pass json to index.html(node.js)?

There is such a query in the database, and a selection in json format gets into line

connection.query("SELECT * FROM chat ORDER BY id DESC LIMIT 5",  function(err, data) {
  data.forEach(function(line){
        console.log(line);
    });
});

How to send this selection to index.html? And how to accept in index.html??
To display data in a loop there. I am newbie. So sorry if it's a dumb question.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
deemaagog, 2017-06-13
@deemaagog

if you use express and a template engine, then
res.render('index',{data});
in template index
each item in data
li= item

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question