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 MockOutThis 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
Create a custom JSON endpoint
Return the exact product, user, or order data your frontend needs.
Test your frontend with real HTTP errors
Exercise expired sessions, rate limits, and server failure screens.
Generate realistic API test data with Faker
Generate fresh names, email addresses, and IDs on each request.