Skip to content

Instantly share code, notes, and snippets.

@waterswv
Last active February 9, 2018 01:54
Show Gist options
  • Save waterswv/0855d42b4a4571a9995b959bc4ff9965 to your computer and use it in GitHub Desktop.
Save waterswv/0855d42b4a4571a9995b959bc4ff9965 to your computer and use it in GitHub Desktop.
API get request by slug
app.get('/:id', function(req, res, next) {
db.Post.findById(req.params.post_id, function(err, mainPost) {
if (err){
console.log('Error', err);
}
app.get('/:slug', function(req, res, next) {
db.Post.findOne({'slug': req.params.slug}, function(err, mainPost) {
if (err){
console.log('Error', err);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment