//这不起作用,请帮助 app.get(“ / dishes /:id”,function(req,res){
dishes.findById(req.params.id, function(err, founddishes){
if(err){
console.log(err);
} else {
// Render show template with that campground
res.render("show", {dishes: founddishes});
}
});
});
答案 0 :(得分:0)
尽管您尚未定义代码发生了什么错误。请再次检查您的路由器,可以使用此代码段作为最佳做法,谢谢您
dishes.findById(req.params.id)
.then((founddishes) => {
if(founddishes){
res.render("show", {dishes: founddishes});
} else {
throw[{msg: "Not found"}]
}
})
.catch((errors) => {
console.log(errors);
})