安装
npm install -g json-server
描述接口数据
\\ test.json
{
"issues": [
{
"id": 101,
"text": "something is not right"
},
{
"id": 102,
"text": "crash on login"
}
],
"total": {
"data": {
"exchange_count": "10",
"share_count": "23",
"patent_count": "7",
"article_count": "37",
"exchangeRecords": []
},
"success": true
}
}
启动服务
json-server --watch test.json --port 9090
此时我们请求/issues和/total接口即可返回json文件中的指定数据了