当前位置:网站首页>uni-app 使用escook/request-miniprogram插件发请求说明
uni-app 使用escook/request-miniprogram插件发请求说明
2022-06-27 11:45:00 【清音啊】
请求说明:
根据接口要求,一般常用的请求类型为get请求和post请求
get的不传参的写法
//res是接口返回的数据,可能包含1.请求结果状态(success)2.数据(data)3.提示(message)
//get请求uni.$http.get;post请求uni.$http.post
//请求路径:/home/Img/goods_video。(此接口仅为示例,自己写的需要根据接口文档实际来写)
const { data: res } = await uni.$http.get('/home/Img/goods_video')
/*例如:res返回的数据为
{
"success": 1, //成功响应
"message": "获取成功",
"data": [
{
"id": 426,
"goods_name": "推送螺旋三角铁",
"phone": ""
}
]
}
*/
if (res.success !== 1){
return uni.$showMsg()
}else{
//List为自定义的参数;res.data表示使用接口返回的data中的数据赋值
this.List = res.data
}
get传参
//params为自定义的,也可以叫data,但是还是params更通俗易懂,里面的参数可以是多个,根据接口文档要求来设计
//search_name为请求参数名,这里只是示例,实际参数名可根据接口文档要求来写
//西服,请求参数值
var params = {
search_name:'西服'
}
const { data: res } = await uni.$http.get('/api/public/v1/home/swiperdata',params)
if (res.success !== 1){
return uni.$showMsg()
}elses{
this.List2 = res.data
}
post不传参
const { data: res } = await uni.$http.post('/home/Infor/newselect')
if (res.success !== 1){
return uni.$showMsg()
}elses{
this.List2 = res.data
}post传参
var params = {
id:123
}
const { data: res } = await uni.$http.post('/home/Infor/newselect2',params)
if (res.success !== 1){
return uni.$showMsg()
}elses{
this.List2 = res.data
}边栏推荐
- namespace ‘rlang’ 0.2.0 is being loaded, but >= 0.3.0 is required
- 数学知识——博弈论(巴什博奕、尼姆博奕、威佐夫博奕)思路及例题
- Popular science of device review: popular science of innovative medical device series - sternum plate products
- How to adjust an integer that is entered in Excel but always displays decimals?
- [tcapulusdb knowledge base] Introduction to tcapulusdb data structure
- Shell script learning notes
- Research Report on the overall scale, major producers, major regions, products and application segments of swine vaccine in the global market in 2022
- MapReduce实战小案例(自定义排序、二次排序、分组、分区)
- 想学好C语言,操作符也很重要
- Research Report on the overall scale, major manufacturers, major regions, products and application segments of hydraulic torque in the global market in 2022
猜你喜欢

Online bidding of Oracle project management system

数学知识——博弈论(巴什博奕、尼姆博奕、威佐夫博奕)思路及例题

Shell script learning notes
![[tcapulusdb knowledge base] tcapulusdb operation and maintenance doc introduction](/img/04/b1194ca3340b23a4fb2091d1b2a44d.png)
[tcapulusdb knowledge base] tcapulusdb operation and maintenance doc introduction

This privatized deployed enterprise knowledge base makes telecommuting a zero distance

0 basic understanding of how e-commerce systems connect with payment channels

mysql学习1:安装mysql
![Dynamic programming [4] (counting class DP) example: integer partition](/img/06/4b3863bbb85582348c6f4ea7c5511e.png)
Dynamic programming [4] (counting class DP) example: integer partition

Rxjs mergeMap 的使用场合

Research Report on the overall scale, major manufacturers, major regions, products and application segments of hydraulic torque in the global market in 2022
随机推荐
[high frequency interview questions] difficulty 1.5/5, LCS template questions
i.mx6ull(单片机) c语言环境搭建
面试突击60:什么情况会导致 MySQL 索引失效?
The R language uses the follow up The plot function visualizes the longitudinal follow-up map of multiple ID (case) monitoring indicators, and uses stress The labels parameter adds label information t
Llvm family (1) - Introduction to llvm
Popular science of device review: popular science of innovative medical device series - sternum plate products
Hands on API development
56. Core principle of flutter - flutter startup process and rendering pipeline
Unity shader learning (I) understanding the basic structure of unity shader
[tcapulusdb knowledge base] tcapulusdb doc acceptance - Introduction to creating game area
alibaba jarslink
Maximum path and problem (cherry picking problem)
[tcapulusdb knowledge base] Introduction to tcapulusdb system management
In 2021, the global carbon graphite brush revenue is about US $2366million, and it is expected to reach US $2701.8 million in 2028
最短编辑距离(线性dp写法)
Shell script learning notes
Jerry's adding timer interrupt [chapter]
[tcapulusdb knowledge base] tcapulusdb OMS business personnel permission introduction
alibaba jarslink
Research Report on the overall scale, major producers, major regions, products and application segments of swine vaccine in the global market in 2022