安装:
npm i json-server -g
使用:
(1) 任意创建一个json文件,json文件内容如下:
{
"data": []
}
(2) 启动json-server
json-server --watch db.json
(3) 写入
curl --location 'http://localhost:3000/data' \ --header 'Content-Type: application/json' \ --data '{ "id":2, "city":"HangZhou" }'(4) 查看数据
curl --location 'http://localhost:3000/data'