Put in order · JavaScript and React course · Module 11: Data Fetching and APIs
Data Fetching Pattern in React
Arrange the elements of the complete data fetching pattern in React (from start to finish):
Items to put in order
- Define states: data (null), loading (true), error (null)
- Call fetch() in a try/catch/finally block
- Update states based on the response
- Create useEffect with an async function inside
- Render conditional UI (loading/error/data)
You can check the correct answer by solving this task in the CodeWorlds game.