安装
npm install -g json-server
创建json文件,示例如下:
{
"posts": [
{
"id": 1,
"title": "json-server",
"author": "typicode"
}
],
"comments": [
{
"id": 1,
"body": "some comment",
"postId": 1
}
],
"profile": [
{
"name": "typicode"
}
]
}
运行
json-server --watch db.json