目的:
做一个本地的mock-server来模拟请求以及请求回来的过程
安装json-server:
npm install -g json-server
创建db.json:
在一个文件夹下新建一个db.json文件
{ "school": [ { "id": 1, "name": "first", "address": "beijing" } ], "student": { "name": "lihua" }}
启动json-server:
在当前文件夹下输入命令:
json-server db.json
成功:
{^_^}/ hi! Loading db.json Done Resources http://localhost:3000/school http://localhost:3000/student Home http://localhost:3000 Type s + enter at any time to create a snapshot of the database