I want to show a post and the respective comments for this I have 2 tables in mysq
l a " post " and the other " comments "
Use mcv
model view controller with nodejs
and express
.
model.js
getOne(id, cb) {
conn.query('SELECT * FROM post WHERE id = ?', id, cb);
}
controller.js
getOne(req, res, next) {
let id = req.params.id;
console.log(id);
bm.getOne(id, (err, data) => {
if(!err) {
res.render('detalles', {
c: data
});
}
});
}
router.js
router.get('/detalles/:id',bc.getOne);