使用json-server搭建模拟api接口
转载:http://blog.csdn.net/adojayfan/article/details/55011674
作为前端和客户端开发人员,在后端还没有给出对应的api接口时,我们无法做测试。
这时,我们可以使用json-server快速搭建一个测试的api接口,能在几十秒之内搭建好。
Github地址:https://github.com/typicode/json-server
使用前提
安装node.js。
进入https://nodejs.org/en/,下载对应的版本安装。
然后使用命令node -v 测试安装是否成功。安装json-server
使用node的npm安装json-server
命令:npm install -g json-server配置
新建一个json文件
{
"posts": [
{ "id": 1, "title": "json-server", "author": "typicode" }
],
"comments": [
{ "id": 1, "body": "some comment", "postId": 1 }
],
"profile": { "name": "typicode" }
}
- 启动json-server
进入创建json所在的路径,我在e盘根目录创建的,所以进入e盘。
使用命令:json-server –watch json文件名
json-server默认使用的是3000端口,在浏览器中打开http://localhost:3000/
出现以下页面说明访问成功。
更详细的配置可以阅读json-server的说明文档。
使用json-server搭建模拟api接口的更多相关文章
- 利用Laravel 搭建oauth2 API接口 附 Unauthenticated 解决办法
利用Laravel 搭建oauth2 API接口 要求 laravel 5.4以上 安装 $ composer require laravel/passport 在配置文件 config/app.ph ...
- 常用的API接口,返回JSON格式的服务API接口
物流接口 快递接口: http://www.kuaidi100.com/query?type=快递公司代号&postid=快递单号 ps:快递公司编码:申通="shentong&qu ...
- 一次php访问sql server 2008的API接口的采坑
2018年6月21日17:17:09,注意:不是详细文档,新手可能会看不懂 windows下安装 项目是sql server 2008的k3,php连接数据库写的API,因为是买的时候是别人的程序,测 ...
- golang 组装返回json数据,提供api接口
model里 package model type Setting struct { Key string `gorm:"primary_key" json:"key&q ...
- Web API接口设计经验总结
在Web API接口的开发过程中,我们可能会碰到各种各样的问题,我在前面两篇随笔<Web API应用架构在Winform混合框架中的应用(1)>.<Web API应用架构在Winfo ...
- 使用RAP2和Mock.JS实现Web API接口的数据模拟和测试
最近一直在思考如何对Web API的其接口数据进行独立开发的问题,随着Web API的越来越广泛应用,很多开发也要求前端后端分离,例如统一的Web API接口后,Winform团队.Web前端团队.微 ...
- Web API接口设计(学习)
1.在接口定义中确定MVC的GET或者POST方式 由于我们整个Web API平台是基于MVC的基础上进行的API开发,因此整个Web API的接口,在定义的时候,一般需要显示来声明接口是[HttpG ...
- IdentityServer4实现.Net Core API接口权限认证(快速入门)
什么是IdentityServer4 官方解释:IdentityServer4是基于ASP.NET Core实现的认证和授权框架,是对OpenID Connect和OAuth 2.0协议的实现. 通俗 ...
- drf基础:1、web应用模式、API接口、接口测试工具
drf入门 一.web应用模式 web的应用模式共分为两种,前后端不分离.前后端分离 1.前后端混合 之前所写的bbs项目就是前后端不分离,后端人员在开发过程中使用模板语法,前后端都由一个人员 ...
随机推荐
- DP———1.最大子连续子序列和
最大连续子序列 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Sub ...
- 洛谷noip 模拟赛 day1 T3
T7983 大芳的逆行板载 题目背景 大芳有一个不太好的习惯:在车里养青蛙.青蛙在一个n厘米(11n毫米s)的Van♂杆子上跳来跳去.她时常盯着青蛙看,以至于突然逆行不得不开始躲交叉弹.有一天他突发奇 ...
- parallel programming. this causual litery nots represents my recent progress in parallel programming in c#.It`s interesting.
not to say extra words,let`s start the code. pasted below: using System; using System.Collections.Ge ...
- md5 加解密
using JGDJWeb.Model; using System; using System.Collections.Generic; using System.IO; using System.L ...
- 关于Local System/Local Service/Network Service账户
部署或安装系统服务时需要指定服务运行的账户.一般地,可选择Local System.Local Service或Network Service账户. Local System/Local Servic ...
- UVA 11125 Arrange Some Marbles
dp[i][j][m][n][s]表示最初选择j个i号颜色大理石.当前选择n个m号颜色大理石.剩余大理石状态(8进制数状压表示)最开始没看出状压..sad #include <map> # ...
- itatis中的数据库配置
<!--com.microsoft.sqlserver.jdbc.SQLServerDriver --> <property name="JDBC.Driver" ...
- Python3在Windows安装配置及简单试用
1,安装配置 安装版本是Python3.5,我的安装路径是E:\ImProgram\Python35 添加环境变量,将上述路径加入到path中 这样cmd打开命令窗口,输入python就能看到调用成功 ...
- Linux下多进程服务端客户端模型一(单进程与多进程模型)
本文将会简单介绍Linux下如何利用C库函数与系统调用编写一个完整的.初级可用的C-S模型. 一.基本模型: 1.1 首先服务器调用socket()函数建立一个套接字,然后bind()端口,开始l ...
- HDU 2602.Bone Collector-动态规划0-1背包
Bone Collector Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...