From the course: Building Modern Projects with React

Unlock this course with a free trial

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

Loading data with Thunks

Loading data with Thunks

- [Instructor] All right, so now that we've created our loading slice, the next thing that we're going to do is we're going to see how to actually start using thunks to load data from our server. Now, there are actually two things that we're going to need to do to make this work. The first thing we're going to need to do is add /api to the start of all of our server routes. Now the reason we have to do this is so that when we make a /api request from our front end, it will know that it's supposed to proxy that to the server. Don't worry too much about that. Basically, this just makes it easier to run these things together in development and send requests between them. So now that we've done that, make sure you add that in four places here. The next thing we're going to need to do is go into this vite.config.js file and we're just going to need to tell our React Vite application that we want it to proxy requests to the server, right? This will save us from having to specify the entire…

Contents