Created
March 14, 2016 21:49
-
-
Save andrewjmead/5a4a80b2121682bcd31b to your computer and use it in GitHub Desktop.
Steve DELETE /todo/:id
This file contains hidden or 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
| var cachedTodo; | |
| db.todo.findById(todoId).then(function(todo){ | |
| if (todo) { | |
| cachedTodo = todo; | |
| return todo.destroy(); | |
| } else { | |
| res.status(404).send('Unable to delete'); | |
| } | |
| }).then(function(rows){ | |
| res.json(cachedTodo); | |
| }).catch(function(){ | |
| res.status(500).send(); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment