JsonServer
Get a full fake REST API with zero coding in less than 30 seconds (seriously)
可以用来创建 RestApi,非常方便.
安装
应该还需要装NodeJs什么的,但是我已经安装过了.1
sudo npm install -g json-server
基本使用
找个地方新建一个db.json文件
写入一段json,如:1
2
3
4
5
6
7
8
9{
"posts": [
{ "id": 1, "title": "json-server", "author": "typicode" }
],
"comments": [
{ "id": 1, "body": "some comment", "postId": 1 }
],
"profile": { "name": "typicode" }
}启动server
1 | json-server --watch db.json |
启动成功后:
接下去就可以访问了:

设置别名
每次都输入json-server --watch 太麻烦了.
我给它配置个别名:1
2jsw
alias jsw="json-server --watch"
记得source ~/.zshrc,这样以后就方便了:
以后可以自己模拟写Api了~
更多功能还需去Github看,不过作为一个Android程序猿,这个已经够了.