Store fixture responses per endpoint/version; frontends hit read-only URLs while backends are in progress.
Your frontend team is ready to build, but the backend API isn't done yet. You need realistic mock responses for different endpoints and versions so development can proceed in parallel.
Setting up a mock server is overkill, and hardcoding responses in the frontend makes them hard to update and share across the team.
Store mock API responses in a WrenDB stash with endpoint names as keys. Frontends fetch from public read URLs. Backend devs update fixtures with the master token. Simple, shareable, and version-controlled.
Create a stash for your API fixtures:
# Create mock API stash
curl -X POST https://wrendb.com/api/stash
{
"stash_id": "mocks456...",
"master_token": "token-api789...",
"message": "Save this token securely..."
}
# Add mock responses for different endpoints
curl -X POST https://wrendb.com/api/item/mocks456.../users-list \
-d '[{"id":1,"name":"Alice"},{"id":2,"name":"Bob"}]'
curl -X POST https://wrendb.com/api/item/mocks456.../user-profile \
-d '{"id":1,"name":"Alice","email":"alice@example.com","role":"admin"}'
curl -X POST https://wrendb.com/api/item/mocks456.../products-v2 \
-d '{"products":[{"id":101,"name":"Widget","price":29.99}],"version":"2.0"}'
Create a simple API client that fetches from WrenDB:
const MOCK_STASH_ID = 'mocks456...';
const USE_MOCKS = true; // Toggle for dev vs production
async function fetchAPI(endpoint) {
if (USE_MOCKS) {
// Fetch from WrenDB - no auth needed
const response = await fetch(
`https://wrendb.com/api/item/${MOCK_STASH_ID}/${endpoint}`
);
return await response.json();
} else {
// Real API call
const response = await fetch(`https://api.yourapp.com/${endpoint}`);
return await response.json();
}
}
// Usage in your app
async function loadUsers() {
const users = await fetchAPI('users-list');
console.log(users); // [{"id":1,"name":"Alice"},...]
}
async function loadUserProfile(userId) {
const profile = await fetchAPI('user-profile');
console.log(profile); // {"id":1,"name":"Alice",...}
}
Backend team updates fixtures as the API design changes:
#!/bin/bash
STASH_ID="mocks456..."
TOKEN="$MOCK_API_TOKEN"
# Update user profile with new fields
curl -X PUT "https://wrendb.com/api/item/$STASH_ID/user-profile" \
-H "Authorization: Bearer $TOKEN" \
-d '{
"id": 1,
"name": "Alice",
"email": "alice@example.com",
"role": "admin",
"avatar_url": "https://example.com/avatar.jpg",
"created_at": "2025-01-15T10:00:00Z"
}'
echo "✅ Mock updated - frontend will get new fields immediately"
Store different versions of the same endpoint:
# v1 endpoint
curl -X POST https://wrendb.com/api/item/mocks456.../products-v1 \
-d '[{"id":101,"name":"Widget","price":29.99}]'
# v2 endpoint with enhanced response
curl -X POST https://wrendb.com/api/item/mocks456.../products-v2 \
-d '{
"products": [
{"id":101,"name":"Widget","price":29.99,"stock":45,"category":"tools"}
],
"version": "2.0",
"total_count": 1
}'