Skip to content

Instantly share code, notes, and snippets.

@andrewjmead
Created March 14, 2016 21:49
Show Gist options
  • Select an option

  • Save andrewjmead/5a4a80b2121682bcd31b to your computer and use it in GitHub Desktop.

Select an option

Save andrewjmead/5a4a80b2121682bcd31b to your computer and use it in GitHub Desktop.
Steve DELETE /todo/:id
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