Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. app.get('/todos/:id', function (req, res) {
  2. var result = db.load(req.params.id);
  3. result ? res.send(result) : res.send(404);
  4. });
  5.  
  6. exports.load = function (id) {
  7. todos.findOne({ id: id }, function (err, todo) {
  8. if (!err) {
  9. return todo;
  10. }
  11. });
  12. }
  13.  
  14. app.get('/todos/:id', function (req, res) {
  15. db.load(req.params.id, function(err, result) {
  16. // also handle err
  17. result ? res.send(result) : res.send(404);
  18. });
  19. });
  20.  
  21.  
  22. exports.load = function (id, callback) {
  23. todos.findOne({ id: id }, callback);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement