当前位置:网站首页>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 ”.
边栏推荐
- Configmap of kubernetes
- Application of workflow engine in vivo marketing automation
- [fluent -- advanced] packaging
- Analyzing method and proc in Ruby
- [arm learning (9) ARM compiler understanding learning (armcc/armclang)]
- srec_cat 常用参数的使用
- Activity之onCreate、onRestoreInstanceState恢复数据的区别
- Jmeter快速上手之接口测试
- The difference and efficiency comparison of three methods of C # conversion integer
- kubernetes之探针
猜你喜欢
![[RCTF2015]EasySQL](/img/68/328ee5cffc8b267b6b0f284eb8db2c.png)
[RCTF2015]EasySQL
![[BJDCTF2020]Easy MD5](/img/6a/61a4b5624c33f1f334bea344cfa2c8.png)
[BJDCTF2020]Easy MD5

SQL statement -- single line comment and multi line comment

Comprehensively design an oppe homepage -- layout and initialization

The "nuclear bomb level" log4j vulnerability is still widespread and has a continuing impact

综合设计一个OPPE主页--顶部,头部的设计

Test cases should never be used casually, recording the thinking caused by the exception of a test case

Comprehensive design of an oppe homepage -- Design of navigation bar

技术风向标 | 云原生技术架构成熟度模型解读

vlang捣鼓之路
随机推荐
The "nuclear bomb level" log4j vulnerability is still widespread and has a continuing impact
C # set different text watermarks for each page of word
Sword finger offer special assault edition day 11
Alibaba cloud DMS MySQL cloud database report error, solve!!
匿名方法和lambda表达式使用的区别
How to configure tke cluster node Max pod
初识OpenGL (3)片段着色器(Fragment Shader)
6种方法帮你搞定SimpleDateFormat类不是线程安全的问题
vscode批量删除
PAT甲级 1046 Shortest Distance
综合设计一个OPPE主页--明星机型的设计
The difference between anonymous methods and lambda expressions
ZABBIX 6.2.0 deployment
Activity之onCreate、onRestoreInstanceState恢复数据的区别
MVC和ECS两种设计架构的初浅理解
面试时候常说的复杂度到底是什么?
C语言重点知识总结
Difference between C event and delegation
基于sisotool极点配置PI参数及基于Plecs的三相电压源逆变器仿真
Re7: reading papers fla/mlac learning to predict charges for critical cases with legal basis