json-server

// db.json
{
  "posts": [
    { "id": 1, "title": "json-server", "author": "typicode" }
  ],
  "comments": [
    { "id": 1, "body": "some comment", "postId": 1 }
  ],
  "profile": { "name": "typicode" }
}
  • 3 启动json-server服务器
    json-server --watch db.json
  • 4 Restfull风格接口
    GET获取
    POST插入
    PUT更新整条数据
    PATCH部分更新
    DELETE 删除数据
    _page 页码
    _limit 每页显示数量,默认10
    GET /posts
    GET /posts/1
    POST /posts
    PUT /posts/1
    PATCH /posts/1
    DELETE /posts/1
    GET /posts?title=json-server&author=typicode
    GET /posts?id=1&id=2
    GET /comments?author.name=typicode
    GET /posts?_page=7
    GET /posts?_page=7&_limit=20
posted on 2022-10-25 11:25  玉龙龙玉  阅读(51)  评论(0)    收藏  举报

……