From the course: Build Modern Web Apps with React, Hooks, State Management, and APIs Using Vite or Next.js

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Deleting a product: DELETE

Deleting a product: DELETE

Hello and welcome back. In this video, we are going to see how we can delete a product using the HTTP delete method. For deleting a product, we need to have a simple component. This component is going to have a delete button. And on delete handler, we can just call the API dot delete method. Similarly, like the update, when deleting a resource, we have to add the resource name and the ID that we want to delete. Because ID is something that uniquely identifies a specific resource item. So we have to use this ID in the update and delete cases. Now let's delete this item that we have added in the list. I'm going to clear down the console. And when I'm going to click on this delete button, we'll have a API request being shown in the network tab. Let's click on delete. You can see that the item has been removed from the list. And when I'm going to click on this API, we can see that we have called the products slash 55 which is the id for that product we deleted and we use the delete method…

Contents