디테일 페이지에 댓글을 보여주고 싶어서 만드는 중인데요,
제목 그대로 상세페이지 get요청 할때 다른 컬렉션 두군데에서 다른 데이터를 두개 받아서 각 페이지에 두개의 데이터를 넣고 싶은데 다양한 방법으로 시도 해봤는데 계속 에러가 납니다,,
일단 이렇게 코드를 짰었는데 에러가나서 어떤식으로 각 페이지에 데이터를 전달 할 수 있을까요..?
comment.ejs는 detail페이지에 include되어 있습니다.
app.get('/detail/:id', function (req, res) {
db.collection('post').findOne({ _id: parseInt(req.params.id) }, function (err, result) {
db.collection('commentroom').find({ postNum: req.params.id }).toArray().then((result) => {
res.render('comment.ejs', { data: result })
})
res.redirect('/detail/:id', { data: result })
})
})