Fake Backend API using JSON Server

Adi Ramadhan
Jan 26, 2023

--

Simple Fake Backend using JSON Server. Official docs

JSON Server run in localhost

Preparation
Install via npm:

npm install -g json-server

Create db.json file

{
"users": [
{
"id": 1,
"username": "user1",
"password": "password"
},
{
"id": 2,
"username": "user2",
"password": "password"
}
]
}

Run via terminal/CMD

json-server --watch db.json

Open localhost:3000

Test GET users with localhost:3000/users

GET all users

Test GET users with localhost:3000/users/?id=1

GET with filter

Create User by POST localhost:3000/users/

{
"username": "user3",
"password": "password"
}
POST users

--

--