Episode 16 of 32
Using JSON Server
Set up a fake REST API using JSON Server for local development and testing.
JSON Server creates a full fake REST API from a JSON file — perfect for development.
Setup
npx json-server --watch data/db.json --port 8000db.json
{
"blogs": [
{ "id": 1, "title": "My Blog", "body": "Content...", "author": "Mario" },
{ "id": 2, "title": "React Tips", "body": "More...", "author": "Yoshi" }
]
}Auto-Generated Endpoints
GET /blogs— All blogsGET /blogs/1— Single blogPOST /blogs— Create blogDELETE /blogs/1— Delete blog