在我的node js应用程序中,我具有以下路由。
router.get('/:id',[auth],asyncHandler(async (req,res) => {
const post = await postService.getPostById(req.params.id);
res.json(post);
}));
router.get('/all',res) => {
const posts = await postService.getallPosts(req.user.id);
res.json(posts);
}));
在这里,当我呼叫发布/所有路线时,它崩溃了。它说,对模型“ Post”的路径“ _id”的
但是,如果我评论第一条路线,第二条路线就可以完美地工作。为什么会这样?