Menu

A Mock with Memory: CRUD, Soft Delete, and Restore Without Writing a Backend
📰

A Mock with Memory: CRUD, Soft Delete, and Restore Without Writing a Backend

DEV Community: frontend·Alejandro Rodriguez·2 days ago
#OWC8cbMS
#devtofrontend#devto#dev#toisostring#enter
Reading 0:00
15s threshold

The frontend already knows how to create a note, mark it as done, and send it to the trash. The mock doesn't. Every GET /api/notes returns the same array, the POST leaves no trace, and the 409 for a duplicate title is something you have to invent by hand. That's enough for a static list. It falls short as soon as an optimistic UI 1 , a trash view, or a conflict shows up.

In Mock Your API in 5 Minutes with JSON and Switch Success and Error Without Touching Your Frontend , the mock was a fixed body and a nameResponse you flipped. This is where the store comes in: an in-memory collection, declared in the same JSON, with list , get , create , update , patch , delete , and restore actions. The examples use http-mock-json 6.0.1, and every response in this article comes from actually running it.

This isn't a guide to every filter, relation, or on-disk persist.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.