100% found this document useful (1 vote)
266 views9 pages

Creating a Dummy API with JSON Server

The document outlines steps to create a dummy API using NodeJS and json-server by installing NodeJS and json-server, creating a students.json file with sample data, and running json-server to make the API available at a local URL.

Uploaded by

Sid Mars
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
266 views9 pages

Creating a Dummy API with JSON Server

The document outlines steps to create a dummy API using NodeJS and json-server by installing NodeJS and json-server, creating a students.json file with sample data, and running json-server to make the API available at a local URL.

Uploaded by

Sid Mars
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
  • Installing NodeJS
  • Environment Setup
  • Running JSON Server

How to create dummy API's

1) Install NodeJS
Download link: [Link]
Set Environment variable:

2) Check node & npm versions ( npm comes along with [Link])

3) install json-server
npm install -g json-server
Ignore this

4) create [Link] file with the following data


{
"students": [
{
"id": 1,
"name": "John",
"location": "india",
"phone": "1234567890",
"courses": [
"Java",
"Selenium"
]
},
{
"id": 2,
"name": "Kim",
"location": "US",
"phone": "98876543213",
"courses": [
"Python",
"Appium"
]
},
{
"id": 3,
"name": "Smith",
"location": "Canada",
"phone": "165498765",
"courses": [
"C#",
"RestAPI"
]
}
]
}
5) Run the below command to make your API's up and running.

json-server --watch [Link]

[Link]

How to create dummy API's 
1) Install NodeJS 
 
Download link: https://nodejs.org/en/download/  (https://nodejs.org/en/downlo
Set Environment variable: 
 
 
 
2) Check node & npm versions ( npm comes along with node.js) 
 
 
 
3) install json-server
4) create students.json file with the following data 
{ 
  "students": [ 
    { 
      "id": 1, 
      "name": "Joh
"Java", 
        "Selenium" 
      ] 
    }, 
    { 
      "id": 2, 
      "name": "Kim", 
      "location": "US",
5) Run the below command to make your API's up and running. 
 
json-server --watch students.json 
 
 
 
 
http://localhost:30

You might also like