当前位置:网站首页>Using JSON server to create server requests locally
Using JSON server to create server requests locally
2022-04-23 16:00:00 【Ten thousand volt little sun】
When the front and back end are developed separately , When the progress of the front and rear ends is inconsistent , The front end needs to test how the request interface is written , The back end hasn't given you an interface yet , You can find some free online api Request address , such as : Baidu api What? . But these api Requests can usually only be tested get request , about post The effect of the request test is not obvious , At this time, we can take advantage of json-server, Spend a few minutes running a small server interface locally .
Next, let's introduce the process :
install json server This package
Create folder json-server
And install... In this directory , Execute the following command :
npm install -g json-server
create file db.js
Write something , representative json Formatted data
{
"posts": [
{
"id": 1, "title": "json-server", "author": "typicode" }
],
"comments": [
{
"id": 1, "body": "some comment", "postId": 1 }
],
"profile": {
"name": "typicode" }
}
Execution instruction :
json-server --watch db.json
After successful operation :
stay 3000 The port opens a server ,api Request address is
http://localhost:3000
Can pass axios Library to initiate the request , On the basis of api URL Some parameters can be followed .
版权声明
本文为[Ten thousand volt little sun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231405456504.html
边栏推荐
- PS为图片添加纹理
- MySQL optimistic lock to solve concurrency conflict
- utils. Deprecated in35 may be cancelled due to upgrade. What should I do
- Install redis and deploy redis high availability cluster
- How do you think the fund is REITs? Is it safe to buy the fund through the bank
- Single architecture system re architecture
- Read the meaning of serial port and various level signals
- JS regular détermine si le nom de domaine ou le chemin de port IP est correct
- R语言中实现作图对象排列的函数总结
- 5分钟,把你的Excel变成在线数据库,神奇的魔方网表excel数据库
猜你喜欢
Nanny Anaconda installation tutorial
Codejock Suite Pro v20. three
实现缺省页面
捡起MATLAB的第(7)天
Matplotlib tutorial 05 --- operating images
API IX JWT auth plug-in has an error. Risk announcement of information disclosure in response (cve-2022-29266)
Master vscode remote GDB debugging
Install redis and deploy redis high availability cluster
MySQL - MySQL查询语句的执行过程
GRBL学习(一)
随机推荐
pywintypes. com_ Error: (- 2147221020, 'invalid syntax', none, none)
Spark 算子之交集、并集、差集
Tencent offer has been taken. Don't miss the 99 algorithm high-frequency interview questions. 80% of them are lost in the algorithm
Pgpool II 4.3 Chinese Manual - introductory tutorial
【第5节 if和for】
Upgrade MySQL 5.1 to 5.610
Grbl learning (I)
[split of recursive number] n points K, split of limited range
贫困的无网地区怎么有钱建设网络?
Vim使用Vundle安装代码补全插件(YouCompleteMe)
捡起MATLAB的第(4)天
如何进行应用安全测试(AST)
Algorithem_ ReverseLinkedList
s16. One click installation of containerd script based on image warehouse
一文掌握vscode远程gdb调试
ESP32编译环境的搭建
ES常用查询、排序、聚合语句
捡起MATLAB的第(3)天
Day (10) of picking up matlab
建设星际计算网络的愿景