How to Create a RESTful API using JSON server
Create a Sample REST-API by using the following steps
STEP 1: Install JSON server in command promt
Run this command in cmd:
npm install -g json-server
STEP 2 : Create a text file and rename it as db.json
STEP 3 : Fill the json file with some data
"cricketers": [
{
"id": 1,
"first_name": "Rahul",
"last_name": "Dravid",
"email": "rahuldravid@gmail.com"
},
{
"id": 2,
"first_name": "Jaspirit",
"last_name": "Bumrah",
"email": "jaspiritbumrah@gmail.com"
},
{
"id": 3,
"first_name": "Ashwin",
"last_name": "Ravinchanran",
"email": "ashwinravichandran@gmail.com"
},
{
"id": 4,
"first_name": "Dinesh",
"last_name": "Karthik",
"email": "dineshkarthik@gmail.com"
},
{
"id": 4,
"first_name": "Mayank",
"last_name": "Agarwal",
"email": "mayankagarwal@gmail.com"
},
{
"id": 5,
"first_name": "Irfan",
"last_name": "Pathan",
"email": "ifranpathan@gmail.com"
},
{
"id": 6,
"first_name": "Rishab",
"last_name": "Pant",
"email": "rishabpant@gmail.com"
},
{
"id": 7,
"first_name": "Ravi",
"last_name": "Bishnoi",
"email": "ravibishnoi@gmail.com"
},
{
"id": 8,
"first_name": "Yusuf",
"last_name": "Pathan",
"email": "yusufpathan@gmail.com"
},
{
"id": 9,
"first_name": "Yuvaraj",
"last_name": "Singh",
"email": "yuvarajsingh@gmail.com"
},
{
"id": 10,
"first_name": "Sachin",
"last_name": "Tendulkar",
"email": "sachintendulkar@gmail.com"
},
{
"id": 11,
"first_name": "Virat",
"last_name": "Kohli",
"email": "viratkohli@gmail.com"
},
{
"id": 12,
"first_name": "Saurav",
"last_name": "Ganguly",
"email": "sauravganguly@gmail.com"
},
{
"id": 13,
"first_name": "Rohit",
"last_name": "Sharma",
"email": "rohitsharma@gmail.com"
},
{
"id": 14,
"first_name": "Mahendra Singh",
"last_name": "Dhoni",
"email": "mahendrasinghdhoni@gmail.com"
},
{
"id": 15,
"first_name": "Virendra",
"last_name": "Shewag",
"email": "virendrasehwag@gmail.com"
},
{
"id": 16,
"first_name": "Ajit",
"last_name": "Agarkar",
"email": "ajitagarkar@gmail.com"
},
{
"id": 17,
"first_name": "Zaheer",
"last_name": "Khan",
"email": "zaheerkhan@gmail.com"
}
]
}