What is JSON Server
JSON Server is based on a static API framework nodejs, and their local static files quickly mapped to static REST API.
As for what a REST API? Please explain this reference Liao Xuefeng teacher on site, very easy to understand. https://www.liaoxuefeng.com/wiki/1022910821149312/1105003357927328
Quick Start
- Json-server installation
npm install json-server # -g global json-server installation
- Create a db.json
1 { 2 "articles":[ 3 { 4 "id":1, 5 "title":"JSP JavaBean", 6 "url":"https://www.runoob.com/jsp/jsp-javabean.html", 7 "comments":[ 8 { 9 "id":1, 10 "user":"Peter", 11 "context":"good article!" 12 },{ 13 "id":2, 14 "user":"Tom", 15 "context":"nice points!" 16 } 17 ] 18 }, 19 { 20 "id":2, 21 "title":"what's REST API?", 22 "url":"https://www.liaoxuefeng.com/wiki/1022910821149312/1105003357927328", 23 "comments":[ 24 { 25 "id":1, 26 "user":"Mary", 27 "context":"valuable article!" 28 },{ 29 "id":2, 30 "user":"Jack", 31 "context":"not bad!" 32 } 33 ] 34 } 35 ], 36 "menu":[ 37 { 38 "id":1, 39 "menu_name":"MainPage" 40 },{ 41 "id":2, 42 "menu_name":"Java" 43 } 44 ] 45 }
- Start json-server service
Server --watch db.json-json
// the following information to identify the success
/ **\{^_^}/ hi!
Loading db.json
DoneResources
http://localhost:3000/articles
http://localhost:3000/menuHome
http://localhost:3000Type s + enter at any time to create a snapshot of the database
Watching...*/