Submodule 22.2: Setting up a Server using json-server
Configuring the Server
Go to your folder location on your desktop and ...
- create a sub-folder with the name
jsonServer
- Download in this folder the
db.json
file
Move to this folder in your terminal window, and type the following at the command prompt to start the server:
json-server --watch db.json
This should start up a server at port number 3000 on your machine. The data from this server can be accessed by typing the following addresses into your browser address bar:
http://localhost:3000/dishes
http://localhost:3000/leaders
http://localhost:3000/feedback
Type these addresses into the browser address bar and see the JSON data being served up by the server. This data is obtained from the db.json file
The json-server also provides a static web server. Any resources that you put in a folder named public in the json-server folder above, will be served by the server: