From the course: Learning Redux Toolkit
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Fetching data from multiple sources
From the course: Learning Redux Toolkit
Fetching data from multiple sources
- [Instructor] Sometimes, we might need to work with multiple sources of data in our React apps. For example, if we stop at ACTP server, and go back to our browser, see that when we reload our app, our product catalog section is blank. We can add a message that there's a user above this other error. But for our app, let's fall back to the productList.json file, whenever the HTTP server is unavailable. To do this, we're going to import product list from data/productList.json, inside of the ProductSlice.js file. So on line two, we have import, productList, from data/productList.json. And in the buildout case for fetchAllProducts.rejected, let's give state.data a value of our imported product list.products RE. So this should be productList.products. We can now go back to our browser and reload the application, and we have products from the productList.json file displayed to us. This is one use case for working…