From the course: Building Modern Projects with React

Unlock the full course today

Join today to access over 24,000 courses taught by industry experts.

Using thunks to delete server resources

Using thunks to delete server resources

From the course: Building Modern Projects with React

Using thunks to delete server resources

- So far we have a thunk for loading Todos from the server and a thunk for creating new Todos on the server. So one of the next logical steps for us is to add a thunk for deleting Todos from the server so that when the user clicks the remove button on one of our Todos, it actually persists those changes. The process for adding this logic to our application is going to be very similar to the previous video where we created new Todos. The main difference here is our interaction with the server endpoint. Instead of sending a post request with a payload like we did in our add Todo request thunk, we're going to be sending a delete request to Todo/id and as a response the server will be sending the Todo that just got deleted, which we'll have to use in our Todo's reducer to remove that Todo locally. So let's open up our thunks js and add a new thunk called RemoveToDoRequest. We'll say export const, RemoveToDoRequest = and…

Contents