当前位置:网站首页>Network data request for wechat applet development
Network data request for wechat applet development
2022-07-25 19:26:00 【Aricl.】
Catalog
Two 、 Configure the legal domain name of the server
3、 ... and 、 Initiate request
Four 、 skip requst Legal domain name verification
5、 ... and 、 About cross domain and Ajax Explanation
One 、 Limit
For security reasons , The applet official makes the following two restrictions on the request of data interface :
- Only request HTTPS Interface of type
- You must first add the domain name of the interface to the trust list

Two 、 Configure the legal domain name of the server
Configuration steps :
- Log in to wechat applet management background link
- Click development
- Development management
- Development and setup
- Server domain name
- Click the upper right corner to modify requst Legitimate domain name


matters needing attention :
- Domain name only supports https agreement
- Domain name cannot be used IP Address or localhost
- The domain name must go through ICP Keep on record ( Back end understanding )
- The server domain name can be applied for at most within one month 5 Time modify ( The information on the official website is incorrect , Community workers have explained )

3、 ... and 、 Initiate request
(1)GET request
// launch GET request
getInfo(){
wx.request({
url: 'https://XXX',// Interface address to be requested
method:'GET',// How to request
data:{
name:'XX',
age:20
},
// Request successful callback function
success:(res)=>{
console.log(res)// Print the object returned by the server
},
// Callback function for request failure
fail:(res)=>{
console.log(' Request data failed !')
},
// Functions that will be executed whether the request is successful or not
complete:(res)=>{
console.log(' Network data request has been sent !')
}
})
},(2)POST request
// launch POST request
getInfo(){
wx.request({
url: 'https://XXX',// Interface address to be requested
method:'POST',// How to request
data:{
name:'XX',
age:20
},
// Request successful callback function
success:(res)=>{
console.log(res)// Print the object returned by the server
},
// Callback function for request failure
fail:(res)=>{
console.log(' Request data failed !')
},
// Functions that will be executed whether the request is successful or not
complete:(res)=>{
console.log(' Network data request has been sent !')
}
})
},(3) Difference between the two
If you want to submit an article , It must only be used post, Because the amount of data is too large ,get Request similar browsers url request , You put an article in url There must be no request in it , If you are just a simple pass id Or less parameters can be used get, There is also a password input suggestion post,post Request parameters are not displayed in clear text url On .
In a word :GET Requests can include parameters in URL in , but POST The request needs to go through request body To pass parameters .
Reference article :GET And POST The popular explanation of the two
Four 、 skip requst Legal domain name verification
If in development , Back end programmers only provide http Interface to protocol , Not available for the time being https Interface to protocol , At this time, in order not to delay the project development progress , You can now set the local settings in the project details of wechat developer tool , take 【 Do not verify legal domain name 、web-view( Business domain name )、TLS Version, and HTTPS certificate 】 Check on , In order to temporarily skip the detection mechanism of legal domain names ( This operation is limited to Development and commissioning stage Use !)

5、 ... and 、 About cross domain and Ajax Explanation
(1) Cross domain problems only exist in browser based systems Web In development . Because the hosting environment of the applet is Wechat client , So the applet is There is no cross domain The problem of .
(2)Ajax The core of the technology is to rely on... In the browser XML HttpRequst This object , Because the hosting environment of the applet is the client , So there is no in the applet “ launch Ajax request ” That's what I'm saying , It's called “ Initiate a network data request ”
边栏推荐
- 小程序毕设作品之微信校园维修报修小程序毕业设计成品(6)开题答辩PPT
- How to analyze qiime2 after obtaining picrust2 results
- Pymoo learning (7): Parallelization
- Flutter 小技巧之优化你使用的 BuildContext
- Network packet multi-layer transmission demonstration
- 微信小程序开发之全局配置与页面配置
- Wechat campus maintenance and repair applet graduation design finished product (7) Interim inspection report
- [applet development] detailed explanation of host environment
- 微信小程序10-微搭模板
- 【小程序开发】你了解小程序开发吗?
猜你喜欢

Wechat campus maintenance and repair application applet graduation design finished product of applet completion work (6) opening defense ppt

微信小程序 29 热搜榜的完善②

Intouch高级报警(报警筛选)

InTouch advanced alarm (alarm filtering)

Pymoo学习 (5):收敛性分析
![[Detr for 3D object detection] 3detr: an end to end transformer model for 3D object detection](/img/22/426bcb8641db5bfe07e8aacf5e8427.png)
[Detr for 3D object detection] 3detr: an end to end transformer model for 3D object detection

Empire CMS whole station | mobile number /qq lianghao mall source code | suitable for mobile terminal

KCon 2022 亮点及议程大揭秘!
![[919. Complete binary tree inserter]](/img/d9/15a9af50893db955d9ebb4d7d4e3d1.png)
[919. Complete binary tree inserter]

小程序毕设作品之微信校园维修报修小程序毕业设计成品(1)开发概要
随机推荐
新瓶装老酒--近期APT32(海莲花)组织攻击活动样本分析
JS 基本类型 引用类型 深/浅克隆复制
Old wine in new bottles -- sample analysis of recent apt32 (sea Lotus) organizational attacks
SQL Server 2019 installation tutorial
telnet安装以及telnet(密码正确)无法登录!
网络数据包多层传输演示
modelsim和quartus联合仿真PLL FIFO等IP核
Website construction of information exchange platform for China Africa South South cooperation based on PHP
Wechat campus maintenance application applet graduation design finished product of applet completion work (3) background function
前夕 - 0day威胁情报
GBASE 8s UDR内存管理_01_mi_alloc
An idea of solving div adapting to screen
Dynamic implementation of wechat applet 27 progress bar and static construction of search box and hot search list
Eve - 0day Threat Intelligence
Youfu force supercomputing provides customized high-performance computing services for customers
Hongmeng - Damiao computing Sketchpad - Introduction
Selenium 设置元素等待的三种方式详解
FPGA based 1080p 60Hz bt1120 interface debugging process record
JS learning notes 17: DOM query exercise
Pymoo learning (6): termination conditions