Skip to content

Instantly share code, notes, and snippets.

@aurerua
Created March 27, 2016 20:56
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 aurerua/07ba3bb5babe64e5c2c1 to your computer and use it in GitHub Desktop.
Save aurerua/07ba3bb5babe64e5c2c1 to your computer and use it in GitHub Desktop.
Goals tracker — Express, NeDB and REST API - GET one
// GET a goal.
// (Accessed at GET http://localhost:8080/goals/goal_id)
app.get('/goals/:id', function(req, res) {
var goal_id = req.params.id;
db.findOne({
_id: goal_id
}, {}, function(err, goal) {
if (err) res.send(err);
res.json(goal);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment