Consolidate duplicated API calls
Merge independently duplicated API calls into a shared data-fetching layer with request deduplication, shared loading/error state, and cache invalidation.
Preview
Copy prompt
The following components each independently make nearly identical API calls, causing duplicate network requests and inconsistent loading states: [Paste code]. Refactor them to share a single data-fetching layer implemented as a hook, store, or service module. Add request deduplication so concurrent calls for the same data result in a single network request, implement shared loading and error state, and define a clear cache invalidation strategy for when the data changes.
More
Refactoring
Prompts
