Calling the DELETE action of the Web API to delete a Todo item

We added code to get, add, and edit a Todo item by calling various Web API actions, such as GET, POST, and PUT, respectively. Now, let's consume the DELETE action in the Web API to delete a matching Todo item. Follow the given steps to do so:

  1. Open todo.service.ts.
  2. Add the deleteTodo function with the following code snippet to delete a matching Todo item by calling the DELETE action in the Web API:
      deleteTodo(todo: Todo) { 
this.http.delete('/api/todos/' + todo.id)
.subscribe(err => console.log(err),
() => console.log('getTodos Complete')
);
}

This code calls the DELETE action along with the id of the Todo item being deleted. The Web API's DELETE action method will retrieve the matching Todo item from the database and delete it.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset