Fetching Data in React
Fetch inside useEffect (or a data library). Track loading / error / success states. In MERN, your Express API is the usual data source.
- Abort or ignore stale responses when deps change.
- Never put secrets in frontend code.
- Show empty and error UI, not just the happy path.
After you read this chapter, use Write (when available) and Quiz on this page to lock it in.