From the course: Building Modern Projects with React

Unlock this course with a free trial

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

Solution: Using Thunks to update server resources

Solution: Using Thunks to update server resources - React.js Tutorial

From the course: Building Modern Projects with React

Solution: Using Thunks to update server resources

(upbeat music) - [Instructor] All right, well hopefully you gave this challenge a try. Let's take a look at the solution. So what I did is I started off by adding a mark to do as completed thunk to the thunks file. So here's what that's going to look like. I'm just going to say export const mark to do as completed. And this one, just like our delete to do thunk had to take the ID of the to do that we wanted to mark as completed as an argument and incorporate that into the asynchronous function that it returned. So here's what this is going to look like. We're going to say async dispatch and let's make sure to spell that correctly there. Dispatch and get state. And now it's going to look pretty similar to what we had here in our delete to do thunk so let's just copy and paste that for a start. And we're going to need this to be a put request. So we'll say axios.put, hopefully you figured that one out. You should have been able to just from the fact that we used get post and delete for…

Contents