DEV Community

Cover image for I Waited 5 Days for a Backend API. So I Built My Own Mock Server.
JohnMith
JohnMith

Posted on • Originally published at snapmock.net

I Waited 5 Days for a Backend API. So I Built My Own Mock Server.

6 months ago, I was working as a frontend developer on an e-commerce project.

Sprint planning was done. I got assigned to build the product listing page. PM said: "Backend API will be ready this week."

That week passed. No API.

"Just 2 more days." -- 2 days turned into a week.

While waiting, I did what every frontend dev has done at some point:

const products = [
  { id: 1, name: "Test Product", price: 99 },
  { id: 2, name: "Test Product 2", price: 199 },
];
Enter fullscreen mode Exit fullscreen mode

Hardcoded data. Built the UI knowing I'd have to rewrite everything once the real API arrived. But what else could I do? The sprint deadline wasn't going to wait.

That's when I thought: "What if there was a tool that could create a real API in seconds -- one I could call with fetch(), and when the backend is ready, I just swap the URL?"

So I built SnapMock.


What is SnapMock?

The idea is simple:

  1. Create a project, add an endpoint like GET /products
  2. Paste your expected response JSON
  3. Get a live URL, call it with fetch() like a real API

When the real backend is ready -- swap the URL -- frontend code stays the same.

But static data wasn't enough. Testing UI with the same "Test User" 100 times is useless.

So I added Dynamic Data -- write {{$fullName}} in your response, and every API call returns a different name. {{$email}} returns a different email. {{$avatar}} returns a different image. Test your UI with diverse, realistic data instead of staring at "John Doe" all day.

Then I kept going:

AI Generator

Type "a list of 10 products with name, price, image, and rating" -- AI generates the full endpoint config. Too lazy to write JSON? Let AI do it.

Conditional Rules (Mock Rules)

One endpoint, multiple responses based on conditions. Send a token -- get 200. No token -- get 401. Query ?error=true -- get 500. No need to create 5 separate endpoints.

Chaos Mode

Turn it on and your API randomly returns 500, 503, timeouts... See if your frontend actually handles errors gracefully. My QA team's favorite feature .

Stateful CRUD

Create a resource called "users" and you automatically get GET, POST, PUT, DELETE. Add a user, delete a user -- data persists. Like having a mini backend.

Import from Anywhere

  • Paste a Swagger/OpenAPI spec -- auto-generate all endpoints
  • Import a Postman Collection -- instant mock API
  • Paste a real API URL -- SnapMock proxies it and creates a mock from the live response

How I Use It Every Day

Here's my actual workflow now:

// During development -- use SnapMock
const API_BASE = 'https://snapmock.net/api/PROJECT_ID';

useEffect(() => {
  fetch(`${API_BASE}/products`, {
    headers: { 'x-snapmock-key': 'YOUR_KEY' }
  })
    .then(res => res.json())
    .then(setProducts);
}, []);

// When backend is ready -- just change the URL
// const API_BASE = 'https://real-api.com';
Enter fullscreen mode Exit fullscreen mode

No more hardcoding. No more waiting. No more rewriting code.


Free to Use

Plan Price Requests/day Projects
Free $0 1,000 5
Pro $9/mo 50,000 10
Ultra $29/mo 500,000 Unlimited

The free plan includes Dynamic Data, Conditional Rules, Sequential Responses, Chaos Mode, and Stateful CRUD. More than enough for most development workflows.


Try It

snapmock.net -- sign up free, create your first mock API in 30 seconds.

If you've ever been blocked by a backend that "will be ready next week," give it a try.

Questions? Drop a comment below -- I read every one!

Top comments (0)