Created
March 27, 2016 20:56
-
-
Save aurerua/07ba3bb5babe64e5c2c1 to your computer and use it in GitHub Desktop.
Goals tracker — Express, NeDB and REST API - GET one
This file contains 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
// 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