Skip to content

Instantly share code, notes, and snippets.

@alexpersian
Created March 24, 2015 14:27
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 alexpersian/4728ba1ff7b6a9a1bab2 to your computer and use it in GitHub Desktop.
Save alexpersian/4728ba1ff7b6a9a1bab2 to your computer and use it in GitHub Desktop.
app.get('/api/posts', function(req, res) {
Post.find(function(err, posts) {
// if there is an error retrieving, send the error
// nothing after res.send(err) will execute if there is one
if (err) {
res.send(err);
}
res.json(posts);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment