We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
$ npm install -g json-server
db.json
{ "records": [ { "id": "1", "date": "2018-05-17", "title": "title 1", "amount": 88 }, { "id": "2", "date": "2018-05-18", "title": "title 2", "amount": 23 }, { "id": "3", "date": "2018-05-19", "title": "title 3", "amount": 3 }, { "id": "4", "date": "2018-05-20", "title": "title 4", "amount": 8 }, { "id": "5", "date": "2018-05-21", "title": "title 5", "amount": 88 } ] }
在db.json目录打开
json-server --watch db.json --port 3006
根据id获取单个详情数据
id
或者 http://localhost:3000/records?id=1
http://localhost:3000/records?id=1
过滤功能:
使用 .更可以访问深层属性,如:GET /posts?id=1&id=2 GET /comments?author.name=typicode
.
GET /posts?id=1&id=2
GET /comments?author.name=typicode
分页展示功能:
准备更新
发送请求,send
注意:这里是全量更新替换
准备添加
准备删除
发送delete请求,send
delete
使用方法与上 json-server相似,这里不再赘述...
json-server
The text was updated successfully, but these errors were encountered:
No branches or pull requests
json-server
1.全局安装
2.创建
db.json
文件3.开启服务并在指定端口更新
在
db.json
目录打开4.get 获取数据
根据
id
获取单个详情数据过滤功能:
分页展示功能:
5.put 更新数据
准备更新

发送请求,send

6.post 添加数据
准备添加

发送请求,send
7.delete 删除数据
准备删除
发送
delete
请求,sendmockapi
使用方法与上
json-server
相似,这里不再赘述...useful links
参考链接
The text was updated successfully, but these errors were encountered: