This is my second post on getting started

JSON – Server USES

As a front-end developer, when the back-end doesn’t give us the interface, we mostly write dead data as placeholder, but we can’t test whether the data can actually be called. We can use jSON-server to create a local service, and when the back-end gives us the interface, We’re replacing the API with the interface that the back end gives us. All we need to do is provide a JSON file and populate it with some data to simulate the RESTful API interface

JSON – download Server

Json-server is a Node module that we downloaded using the NPM package management tool

npm install -g json-server

Copy the code

After the successful run we create a file with the suffix json

Using json – server

I’m calling it db.json

Let’s put some data in thereWe type on the current command line

json-server db.json
Copy the code

The program is runningWe copy the port and open it in the browser to see our data (the default port is 3000).We have the service started locally

We can request data through Axios or Ajax and display it on our page. This is the json-server command, you can try it yourself