From the course: Building Modern Projects with React

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using thunks to create server resources

Using thunks to create server resources

From the course: Building Modern Projects with React

Start my 1-month free trial

Using thunks to create server resources

- [Narrator] Currently our app is loading and displaying server data correctly. But even though it looks like it's creating new Todos correctly, for example, if we add one up here, when we create a new Todo, the changes only take place locally. Our new Todos aren't persisted in the server. In this video, we'll see how to make this happen using thunks. So, if you remember from an earlier video, and I'm just going to use Postman here for a second to demonstrate something, the way we create a Todo on our server is by sending a post request to the Todos endpoint, with the text for the new Todo as the body of the request. If we send this request, the server will then create this new Todo and return the created Todo as the response to our request. Now our server will also add a unique ID, a createdAt property and an isCompleted property to our Todo for us, so we'll want to be sure to save the Todo that we get back…

Contents