JSON Server - Rest API Installation
JSON Server enables frontend developers to quickly spin up a fake REST API to validate how an app’s interface reacts when receiving data from the backend. This is especially useful when the required backend routes have not been finished yet.
REST stands for representational state transfer and was created by computer scientist Roy Fielding
JSON Server , package
Get a full fake REST API with zero coding in less than 30 seconds (seriously),Created with <3 for front-end developers who need a quick back-end for prototyping and mocking.
JSON Server Package / github.com/typicode/json-serverInstalling JSON Server
Before we can send any request, we need to install JSON Server. Preferably, we’d use npm to install the json-server
package globally.
Global Installation ::
Local Installation
Now that JSON Server has been globally installed, we can create our first server configuration.
Understanding the JSON Server configuration
The next step is to create our first db.json
file, which holds the JSON configuration for the fake REST API. Below is a sample configuration, which includes three endpoints: authors, books, and library.
Starting your first JSON Server
OR to create db.json
To start the server and serve the above endpoints, we’ll use the json-server
command in the command line. We’ll tell the json-server
command to watch our db.json
configuration file.
GET
request to http://localhost:3000/
. If it returns a result, you are ready to explore other endpoints.after successful installation you will get this kind of output
POST MAN : Fake API , Data