Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app.get('/todos/:id', function (req, res) {
- var result = db.load(req.params.id);
- result ? res.send(result) : res.send(404);
- });
- exports.load = function (id) {
- todos.findOne({ id: id }, function (err, todo) {
- if (!err) {
- return todo;
- }
- });
- }
- app.get('/todos/:id', function (req, res) {
- db.load(req.params.id, function(err, result) {
- // also handle err
- result ? res.send(result) : res.send(404);
- });
- });
- exports.load = function (id, callback) {
- todos.findOne({ id: id }, callback);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement