json-server 安装和使用

安装:


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'





标签: 、面试
  • 回复
隐藏