当前位置:网站首页>json-server的使用
json-server的使用
2022-04-21 13:36:00 【阿波罗尼斯圆不是圆】
json-server的使用
作为一个前端,在后端还没有ready的时候,不可避免的要使用mock的数据。很多时候,我们并不想使用简单的静
态数据,而是希望自己起一个本地的mock-server来完全模拟请求以及请求回来的过程。json-server是一个很好的可以替
我们完成这一工作的工具。
说明: 可以快速把一个json文件托管成一个 web 服务器(提供接口)
**特点:**基于Express,支持CORS和JSONP跨域请求,支持GET, POST, PUT和 DELETE 方法
1.安装json-server
npm i -g json-server

2.在随便一个目录中创建一个db.json的文件(名字任意)
内容只要是json格式的就行
{
"brands":[{
"name":"TCL",
"id":1
},{
"name":"Apple",
"id":2
},{
"name":"BM",
"id":3
}]
}
3.启动json-server

进入所在文件的目录,输入以下代码以启动
json-server --watch --port 3002 db.json
我们就可以访问到了

版权声明
本文为[阿波罗尼斯圆不是圆]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_44675969/article/details/108641068
边栏推荐
- [csnote] DB exception (redundant data, modification exception, deletion exception, insertion exception)
- How many insurance evaluation companies are there in Haikou? Where is it specificly? Where can I find it?
- 跑步运动耳机哪个牌子好、适合运动的耳机
- Suggestion: Alt + X marks the marked area. Can I cancel the marking?
- 万字干货!帮你深度掌握设计中的「光影」知识点
- 一文读懂Faster RCNN
- Exercise questions and answers of basic theories and relevant laws and regulations in 2022 supervision engineer examination
- News compendium of foreign Internet products last week - Angel
- A great peripheral driver library! (based on stm32f4)
- MySQL analysis on how to reduce conflict and improve performance of row lock
猜你喜欢

如何在Centos下卸载OpenJDK,安装Oracle JDK

Can great talents be of little use? Oceanbase integration scenario test
![BUUCTF [第三章 web进阶]逻辑漏洞](/img/fb/99a5c60979970a9d6cd0fe0e0fb7a4.png)
BUUCTF [第三章 web进阶]逻辑漏洞

Wechat hidden function series: wechat regular reminder, 2 steps, to relax yourself when you are busy

Hcip road OSPF expansion configuration

JDBC 和数据库连接池

Industry video super resolution new benchmark, Kwai & Dalian research, boarded CVPR 2022

Which brand of running headphones is good and suitable for sports

前馈神经网络

百度地图开发自定义信息窗口openInfoWindow样式
随机推荐
leetcode:824. Goat Latin [simple string manipulation]
A great peripheral driver library! (based on stm32f4)
通讯录的动态实现
3-4Dom形XSS详解以及演示
哈夫曼编码
Huffman coding
thread库和 asio 库区别
2022 supervision engineer contract management exercises and answers
Which brand of running headphones is good and suitable for sports
MySQL使用安装pip和binlog2sql
Industry video super resolution new benchmark, Kwai & Dalian research, boarded CVPR 2022
微信隐藏功能系列:微信定时提醒,2个步骤,让忙碌中的自己松口气
如何在Centos下卸载OpenJDK,安装Oracle JDK
【数字信号处理】线性常系数差分方程 ( 根据 “ 线性常系数差分方程 “ 与 “ 边界条件 “ 确定系统是否是 “ 线性时不变系统 “ 案例 | 使用递推方法证明 )
leetcode:513. 找树左下角的值【简单bfs找每层第一个】
[digital signal processing] correlation coefficient (concept of correlation coefficient | energy signal and power signal | causality of system)
leetcode:513. Find the value in the lower left corner of the tree [simply BFS find the first one in each layer]
CV technical guide free knowledge planet
Flink相关API开发及运行架构和实现原理详解
20210818 diary