Last active
October 31, 2019 08:15
-
-
Save barmgeat/ef050c67bcac03216b4e218aef788254 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
router.get('/getOne', async(req, res) =>{ | |
try { | |
if(!req.query.id){ | |
throw {message: 'add the post id in the request'} | |
} | |
const id = req.query.id; | |
//be carful to add the the tags field name in the model | |
//and not the Model Name or ref | |
const post = await Post.findById(id).populate('tags'); | |
res.status(200).json(post); | |
} catch (error) { | |
res.status(400).json({error: error.message}) | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment