From the course: Building React and Django Apps

Deleting an item using React and Django

From the course: Building React and Django Apps

Start my 1-month free trial

Deleting an item using React and Django

- [Instructor] Right now the wishlist functionality only allows adding items to the wishlist. We're going to change this toggle a wishlist method, to allow deleting wishlist items. In the service API class, we update the wishlist delete method, we reuse the configuration, for sending http requests, which includes the ilog token, and then we return the resulting promise from the Axios, delete method. Now we need to override the destroy method of the wishlist item view set, on the Django side of things. We use pk, the primary key, as the package id, and then we search for the wishlist item, we delete the item, we delete the item from cache, and then we return a two hundred okay response with a short message. Now we run the development servers, we open up the network panel network panel, the dev tools, and so when we click to add a wishlist item, we see the request go through, the icon changes, we can see the response there, and then when we delete the item from the wishlist, we see the corresponding delete method. We can also check the Django admin, to see what wishlist items there are.

Contents