Client code handles the 200 case fine. The 401 that needs a token refresh, the 422 with field-level errors, the 429 with a Retry-After — those are where it breaks. Pick a status here and get a complete, correctly shaped response for it.
What you can control
- Error bodies carry a type, a message, a code and a request ID, which is the shape most real APIs use.
- A 422 includes field-level validation details, so you can test inline error rendering.
- Response headers include rate-limit and request-ID fields that clients commonly read.
- The pagination envelope wraps list responses with page metadata and navigation links.
Testing ideas
- Error states. Generate 400, 401, 404, 422 and 500 responses and check that each produces the right message, not a blank screen.
- Headers. Include headers to test rate-limit displays, request-ID logging and cache behaviour.
- Latency. Turn on the simulated latency header and build loading states that do not flash on fast responses.
- Envelopes. Toggle the pagination envelope to check your client handles both bare arrays and
{ data, meta }bodies. The guide Mocking REST APIs for frontend development shows how to serve these with MSW.
What this is not
This produces static response text for use in a mock server or a fixture file. It does not stand up a live endpoint.