三步使用 JSON Server 模拟 API
来源:互联网 发布:linux scp定义算法 编辑:程序博客网 时间:2024/06/06 12:39
有了设计图之后,后端的 API 往往也才刚刚开始做,在这个时候,能有一个原型工具模拟一份 API 会让一切过的开心很多。
安装
第一步当然是安装啦
Homebrew
Homebrew 是 Mac 上的第三方库管理工具,我们使用 Homebrew 来安装 Node.js
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Node.js
brew install node
json-server
npm install -g json-server
创建 db.json
找个你喜欢的目录,创建 db.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 来启动 Server
测试
启动起来之后,json-server 会根据你的 db.json 自动建立 RESTful API,以上面的 db.json 的 post 为例
GET /posts GET /posts/1 POST /posts PUT /posts/1 PATCH /posts/1 DELETE /posts/1
更深入的使用方式,可以参考 json-server 的官方文档。
阅读全文
0 0
- 三步使用 JSON Server 模拟 API
- 使用json-server搭建模拟api接口
- 使用json-server模拟REST API
- 用JSON-server模拟REST API
- Vue-cli 使用json server在本地模拟请求数据
- json-server本地模拟数据工具的使用
- ServletDemo---模拟天气预报API(JSON数据)
- 使用json-server
- JSON-Server使用
- json-server模拟接口获取mock数据
- json-server+mockjs 模拟REST接口
- Json-Server模拟数据接口开发
- MockJs结合json-server模拟后台数据
- 使用API模拟鼠标事件
- 简单三步堵死SQL Server注入漏洞
- 三步配置jboss和apache http server配置
- 三步完成,sql server 2014 实例迁移
- Ethereum JSON-Api 的使用
- 575. Distribute Candies
- java中使用反射机制获取实体类集合的某个属性值
- CC3200 学习
- 进程间通信 之 pipe(Linux)
- 冒泡排序
- 三步使用 JSON Server 模拟 API
- 微生物相关网络构建教程中文Microbial association network construction tutorial
- javax.net.ssl.SSLHandshakeException的解决办法
- js tab小程序
- typeof,松散相等性和严格相等性
- sql
- 高级面向对象之 类式继承
- ASP.NET中的几种弹出框提示
- 单例模式不单例