API Testing & Debugging
Test your endpoints with the built-in API tester and debug issues quickly
Built-in API Tester
Mock API Builder includes a powerful built-in API testing tool, similar to Postman, that lets you test your endpoints without leaving the application.
Key Features
- ✓ Test all HTTP methods (GET, POST, PUT, PATCH, DELETE)
- ✓ View formatted JSON responses
- ✓ Inspect response headers and status codes
- ✓ Measure response times
- ✓ Save and reuse requests
- ✓ Test with custom headers and query parameters
Testing Different HTTP Methods
Retrieve data from your endpoints
Get All Users:
GET http://localhost:3000/api/usersGet Single User:
GET http://localhost:3000/api/users/1With Query Parameters:
GET http://localhost:3000/api/users?page=1&limit=10Expected Response:
200 OKCreate new resources
Endpoint:
POST http://localhost:3000/api/usersHeaders:
Content-Type: application/jsonBody:
{
"name": "John Doe",
"email": "john@example.com"
}Expected Response:
201 CreatedUpdate entire resources
Endpoint:
PUT http://localhost:3000/api/users/1Body:
{
"name": "John Smith",
"email": "john.smith@example.com"
}Expected Response:
200 OKRemove resources
Endpoint:
DELETE http://localhost:3000/api/users/1Expected Response:
204 No ContentUsing External Tools
You can also test your APIs using popular external tools:
GET Request:
curl http://localhost:3000/api/usersPOST Request:
curl -X POST http://localhost:3000/api/users \ -H "Content-Type: application/json" \ -d '{"name":"John Doe"}'- Open Postman
- Create a new request
- Enter your endpoint URL
- Select HTTP method
- Add headers Authorization (Bearer API token)
- Click Send
// GET request
const response = await fetch('http://localhost:3000/api/users');
const users = await response.json();
// POST request
const response = await fetch('http://localhost:3000/api/users', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'John Doe',
email: 'john@example.com'
})
});Understanding Response Codes
• 200 OK - Request successful
• 201 Created - Resource created successfully
• 204 No Content - Success, no response body
• 400 Bad Request - Invalid request data
• 401 Unauthorized - Authentication required
• 404 Not Found - Resource doesn't exist
• 429 Too Many Requests - Rate limit exceeded
• 500 Internal Server Error - Server error
• 503 Service Unavailable - Server overloaded
Common Issues & Solutions
Problem: "Access to fetch blocked by CORS policy"
Access-Control-Allow-Origin errorSolution: Mock API Builder automatically handles CORS. If testing from a different domain:
- • Ensure your dev server is running on localhost
- • Check if you're using the correct port (3000)
- • CORS headers are automatically set for all origins
Problem: Endpoint returns 404 error
Checklist:
- ✓ Verify the endpoint path matches exactly
- ✓ Check if the project slug is correct
- ✓ Ensure the endpoint was saved in project settings
- ✓ Confirm the HTTP method is enabled for this endpoint
Problem: Response is not valid JSON
Solution:
- • Check your schema definition for syntax errors
- • Ensure all mock data follows the schema
- • Look for missing commas or brackets
- • Use the JSON validator in the schema editor
Problem: API responses are taking too long
Solutions:
- • Reduce the number of mock records (try 100 instead of 10,000)
- • Simplify nested objects in your schema
- • Use pagination for large datasets
- • Check database connection in logs
Debugging with Request Logs
Every API request is automatically logged for debugging:
Each log entry shows:
- • Timestamp (when the request was made)
- • HTTP method and endpoint path
- • Status code (200, 404, 500, etc.)
- • Response time (in milliseconds)
- • Request headers and body
- • Query parameters
- • Client IP address
Access Logs:
Go to your project → Logs tab to view all requests
Testing Best Practices
Don't just test GET requests. Verify POST, PUT, PATCH, and DELETE work correctly.
- • Invalid IDs (non-existent resources)
- • Empty request bodies
- • Very large payloads
- • Special characters in data
API responses should be under 200ms for good UX. Use logs to track performance.
After testing with tools, integrate with your actual frontend app to ensure everything works end-to-end.