Skip to content

Instantly share code, notes, and snippets.

@OdongAlican
Last active May 4, 2020 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OdongAlican/c0871508362f583f5dbf3a26b77fd168 to your computer and use it in GitHub Desktop.
Save OdongAlican/c0871508362f583f5dbf3a26b77fd168 to your computer and use it in GitHub Desktop.
exports.params = async function (req, res, next, id) {
console.log(id);
await PostModel.findById(id)
.populate('author')
.exec()
.then((post) => {
if (!post) {
return res.status(400).send(' post with that Particular id');
}
req.post = post;
next();
})
.catch((err) => {
res.send(err);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment