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
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
Why do you need Redux Thunk?1m 57s
-
(Locked)
How does Redux Thunk work?2m 51s
-
(Locked)
Adding Redux Thunk to React2m 30s
-
(Locked)
Creating a thunk3m 30s
-
(Locked)
The Todos API2m 18s
-
(Locked)
Async thunks5m 56s
-
(Locked)
Adding another reducer7m 19s
-
(Locked)
Refactoring the todos reducer2m 50s
-
(Locked)
Using thunks to create server resources5m 58s
-
(Locked)
Using thunks to delete server resources4m 46s
-
(Locked)
Challenge: Using thunks to update server resources1m 14s
-
(Locked)
Solution: Using thunks to update server resources3m 34s
-
-
-
-
-