There is a small project at nodejs + express + postgres for self-education. By requesting Postgres I get data in json format, then the data on the express tools is rendered to the ejs template. The very question is how do I add this json to a dynamic table in html.
The request to the database looks like this
const pool = new pg.Pool(config);
router.get('/index', (req, res, next) => {
pool.connect(function (err, client, done) {
if (err) {
console.log("Can not connect to the DB" + err);
}
client.query('SELECT * FROM srt_final WHERE info_init @> \'{"subscriber":"999999"}\' ORDER BY id DESC LIMIT 20', function (err, result) {
done();
if (err) {
console.log(err);
res.status(400).send(err);
}
var osaka = result.rows;
res.render('index', { srt: osaka });
})
})
});
The data itself looks like this (about 30 values).
[
{"id":11653167,"info_init":
{"date":"05.07.2018"},
....
{"Time":"10:31:17"}
},
....
{"id":11653168,"info_init":
{:},
......
{:}
}
]