Saturday, 4 August 2018

Render multiple postgres results to same html file

I have a query that returns results from my database, but I don't see how I can have it give me results from multiple queries.router.get("/", function(req, res) { pg.query("SELECT * from tic", (err, done) => { if (err) { console.log(err); } res.render("index", { tic: done.rows }); }); }); I was trying along the lines of this, but cant get it to work since he render statement is inside the query and I can get the render to see the results when I move it out of thererouter.get("/", function(req, res) { pg.query("SELECT * from tic", (err, tic) => { if (err) { console.log(err); } pg.query("SELECT * from tac", (err, tac) => { if (err) { console.log(err); } }); res.render("index", { tic: tic.rows }, { tac: tac.rows}); });

Submitted August 04, 2018 at 05:37PM by Storm-Spirit

No comments:

Post a Comment