JSON Server创建RESTAPI工具

联合创作 · 2023-10-01 15:06

JSON Server 用来创建 RestApi,使用非常的方便。

安装

安装之前,需要已经安装好NodeJs.

$ sudo npm install -g json-server


基本使用

新建一个db.json文件写入一段json,如:

{
 "posts": [
 { "id": 1, "title": "json-server", "author": "typicode" }
 ],
 "comments": [
 { "id": 1, "body": "some comment", "postId": 1 }
 ],
 "profile": { "name": "typicode" }
}

启动server

json-server --watch db.json
浏览 1
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报