Mock API examples

Test your frontend with real HTTP errors

Create mock endpoints that return HTTP 401, 429, or 500. Test expired sessions, rate limits, and server errors with editable JSON responses.

Open this example in MockOut

This fills in the form. Review it, then select Create Endpoint to make it live.

Test each failure deliberately

Choose an example to prefill a GET endpoint with the matching status and JSON body. Each creates a separate endpoint when you submit the form, so you can switch your frontend between success and failure scenarios.

  • 401 Unauthorized: show a sign-in prompt and preserve the work the user was doing. This simulates the response; it does not enforce authentication.
  • 429 Too Many Requests: show a retry message. The example includes Retry-After: 60 and retryAfterSeconds in the JSON. A browser may not expose the header to JavaScript unless the server's CORS configuration allows it; the JSON value is available in the response body.
  • 500 Internal Server Error: replace an endless loading spinner with an error message and retry control.

Why didn't fetch enter catch?

HTTP 4xx and 5xx responses still resolve the fetch promise. Check response.ok before treating a request as successful. Network failures reject the promise separately.

try {
  const response = await fetch("PASTE_YOUR_ENDPOINT_URL");
  if (!response.ok) {
    throw new Error("HTTP " + response.status);
  }
  const data = await response.json();
  console.log(data);
} catch (error) {
  // Replace this with your UI's error state.
  console.error("Request failed", error);
}

These examples always return the configured status. They do not simulate a timeout, automatically recover, or apply a real rate limit.

Start with a real testing problem

Read the full API documentation