React API Layer Architecture
SKILL.md
React API Layer Architecture
A consistent API layer is crucial for preventing "spaghetti code" in asynchronous logic. This document outlines the standards for handling data fetching in this project.
1. Core Principles
- Centralized Configuration: Never call
fetchoraxios.getdirectly in a component. Always use the configured HTTP client. - Typed Responses: Every API call must return a typed response (or Zod schema validated data).
- Hooks for Data Access: Components (or their ViewModels) consume Hooks (
useGetUser), not Promises (api.getUser()). - Error Normalization: Errors should be caught and formatted in the global interceptor before reaching the UI layer.