이게 제가 친 코드입니다.
app.get('/edit:id', function (요청, 응답) {
db.collection('post').findOne({ _id: parseInt(요청.params.id) }, function (에러, 결과) {
응답.render('edit.ejs', { post: 결과 })
if(에러){console.log(에러)}
})
});
------------
이게 코애님이 친 코드입니다.
app.get('/edit/:id', function(요청, 응답){
db.collection('post').findOne({ _id : parseInt(요청.params.id) }, function(에러, 결과){
응답.render('edit.ejs', { post : 결과 })
})
});
--------------
제가 친 코드는 edit으로 겟 요청이 안갑니다.
코애님이 만든 코드는 ㅈㄴ 잘갑니다.
app.get('/edit:id', function (요청, 응답) {
db.collection('post').findOne({ _id: parseInt(요청.params.id) }, function (에러, 결과) {
응답.render('edit.ejs', { post: 결과 })
// if(에러){console.log(에러)} <-이부분 주석처리해도
})
});
Cannot GET /edit/14
웹에서 이렇게 응답을 해줍니다. 혹시 문제가 어떤것인지 알 수 있나요?