In my node js application, I have the following routes.
router.get('/:id', [auth], asyncHandler(async (req, res) => {
const post = await postService.getPostById(req.params.id);
res.json(post);
}));
router.get('/all', [auth], asyncHandler(async (req, res) => {
const posts = await postService.getAllPosts(req.user.id);
res.json(posts);
}));
Here, when I call the post/all route, it gets crashed. It says, Cast to ObjectId failed for value "all" at path "_id" for model "Post"Cast to ObjectId failed for value "all" at path "_id" for model "Post"
But if I comment the first route, second one works perfectly. Why is this happening?