当前位置:网站首页>Wechat applet - network data request
Wechat applet - network data request
2022-07-26 16:28:00 【Front end Xiaobai is moving forward】
Catalog
Learning notes
Alicloud disk : https://www.aliyundrive.com/s/5Zrfw9EpKwa
Extraction code :37sc
Network data request
Restrictions on network data requests in applets
In consideration of safety , The applet official makes the following two restrictions on the request of data interface :
- Only request
httpsInterface of type - The domain name of the interface must be added to the trust list

To configure request Legitimate domain name
Requirements describe : Suppose in your own wechat applet , Hope request https://www.escook.cn/ Interface under domain name
Configuration steps : Log in to wechat applet management background -> Development -> Development and setup -> Server domain name -> modify request 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
- The server domain name can be applied for at most within one month 5 Time modification
launch get request
Call the information provided by wechat applet wx.request() Method , Can initiate GET Data request , The sample code is as follows :
launch post request
Call the information provided by wechat applet wx.request() Method , Can initiate POST Data request , The sample code is as follows :
Request data when the page is loaded
In many cases , We need to load the page at the beginning , Automatically request some initialization data . At this time, you need to enter the... On the page onLoad Calling function to get data in event , The sample code is as follows :
skip request Legal domain name verification
If the back-end programmer Only... Is provided http Interface to protocol 、 Not available for the time being https Interface to protocol . At this time, in order not to delay the progress of development , We can use wechat developer tools , Temporarily open 「 The development environment does not verify the requested domain name 、TLS Version and HTTPS certificate 」 Options , skip request Verification of legal domain name .
Be careful : skip request Options for legal domain name verification , Use only during the development and commissioning phase !
About Cross domain and Ajax Explanation
Cross-domain problem Is only found in browser-based Web In development . because The host environment of the applet Not a browser , It is Wechat client , therefore There is no cross domain problem in applets .
Ajax The core of the technology is to rely on... In the browser XMLHttpRequest This object , because The hosting environment of the applet is wechat client , So in the applet It can't be called “ launch Ajax request ”, It is called “ Initiate a network data request ”.
边栏推荐
- Nacos win10 安装配置教程
- Want the clouds in the picture to float? Video editing services can be achieved in three steps with one click
- Activity之onCreate、onRestoreInstanceState恢复数据的区别
- Re7:读论文 FLA/MLAC Learning to Predict Charges for Criminal Cases with Legal Basis
- How to test the circle of friends (mind map)
- Internet Protocol
- 最终一致性性分布式事务 TCC
- 【万字长文】使用 LSM-Tree 思想基于.Net 6.0 C# 实现 KV 数据库(案例版)
- TKE集群节点max-pod是如何配置的
- The difference between oncreate and onrestoreinstancestate recovery data of activity
猜你喜欢

DTS is equipped with a new self-developed kernel, which breaks through the key technology of the three center architecture of the two places Tencent cloud database

Comprehensively design an oppe homepage -- layout and initialization

微信小程序---网络数据请求

Re8: reading papers Hier spcnet: a legal stat hierarchy based heterogeneous network for computing legal case

互联网协议

A preliminary understanding of MVC and ECS design architectures

Internet Protocol

MVC和ECS两种设计架构的初浅理解

测试用例千万不能随便,记录由一个测试用例异常引起的思考

Comprehensively design an oppe homepage -- the design of the top and head
随机推荐
可信隐私计算框架“隐语”开源专家观点集锦
The process and harvest of developing browser plug-ins with clojurescript
Sql语句——单行注释与多行注释
Mapwithstate of spark streaming state flow
Advanced CAD exercises (I)
Pat grade a 1046 shortest distance
NUC 11 build esxi 7.0.3f install network card driver-v2 (upgraded version in July 2022)
PAT甲级 1046 Shortest Distance
Modify the password of the root user of MySQL database
Simulation of three-phase voltage source inverter based on SISOTOOL pole assignment PI parameters and pless
Want the clouds in the picture to float? Video editing services can be achieved in three steps with one click
Comprehensive design of an oppe homepage -- Design of navigation bar
The "nuclear bomb level" log4j vulnerability is still widespread and has a continuing impact
TKE集群节点max-pod是如何配置的
Draw a beautiful outline of the middle school playground and generate longitude and latitude data
C # set different text watermarks for each page of word
Pat grade a 1050 string subtraction
该怎么写单元测试呢
Reflections on the mystery of Silicon Valley
DTS is equipped with a new self-developed kernel, which breaks through the key technology of the three center architecture of the two places Tencent cloud database