当前位置:网站首页>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
}边栏推荐
- [tcapulusdb knowledge base] tcapulusdb system user group introduction
- Build the Internet of things system from scratch
- Wechat applet realizes five-star evaluation
- i.mx6ull(单片机) c语言环境搭建
- Nifi from introduction to practice (nanny level tutorial) - identity authentication
- Four memory areas (stack, heap, global, code area)
- C # WPF realizes undo redo function
- 2022ciscn central China Web
- MapReduce principle analysis (in-depth source code)
- [tcapulusdb knowledge base] tcapulusdb doc acceptance - table creation approval introduction
猜你喜欢

Detailed explanation of interprocess communication

干货!零售业智能化管理会遇到哪些问题?看懂这篇文章就够了

JSP自定义标签

动态规划【三】(区间dp)石子合并

Topic37——64. 最小路径和

Usage of rxjs mergemap

Excel中输入整数却总是显示小数,如何调整?

In 2021, the global enhanced oil production surfactant revenue was about USD 202.3 million, and it is expected to reach USD 297.1 million in 2028

L'utilisation de C language 0 length Array

2022CISCN华中 Web
随机推荐
在 Golang 中构建 CRUD 应用程序
R语言使用epiDisplay包的poisgof函数对泊松回归(Poisson Regression)执行拟合优度检验、检验是否存在过度离散问题(overdispersion)
Four memory areas (stack, heap, global, code area)
Drive to APasS! Use Mingdao cloud to manage F1 events
Leetcode 177 The nth highest salary (June 26, 2022)
等等, 怎么使用 SetMemoryLimit?
Mathematical knowledge -- ideas and examples of game theory (bash game, Nim game, wizov game)
动态规划【四】(计数类dp)例题:整数划分
Don't miss it. New media operates 15 treasure official account to share
L'utilisation de C language 0 length Array
Popular science of device review: popular science of innovative medical device series - sternum plate products
Daily leetcode force deduction (21~25)
R language uses GLM function to build Poisson logarithm linear regression model, processes three-dimensional contingency table data to build saturation model, uses step function to realize stepwise re
最短编辑距离(线性dp写法)
Unity shader learning (I) understanding the basic structure of unity shader
How to modify a node_ Files in modules
Summary of qstype class usage (II)
master公式
Excel中输入整数却总是显示小数,如何调整?
Dynamic programming [III] (interval DP) stone merging