当前位置:网站首页>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 ”.
边栏推荐
猜你喜欢

【万字长文】使用 LSM-Tree 思想基于.Net 6.0 C# 实现 KV 数据库(案例版)

vlang捣鼓之路

2022年最新西藏建筑施工架子工(建筑特种作业)模拟考试试题及答案

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

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

Docker install redis? How to configure persistence policy?

SQL statement -- single line comment and multi line comment

综合设计一个OPPE主页--明星机型的设计

2022 Niuke summer multi school training camp 1 (acdgij)
![[ten thousand words long text] Based on LSM tree thought Net 6.0 C # realize kV database (case version)](/img/84/640de0bf779cd45498204909be56d1.png)
[ten thousand words long text] Based on LSM tree thought Net 6.0 C # realize kV database (case version)
随机推荐
guetzli简单使用
Collection of open source expert opinions on trusted privacy computing framework "argot"
Bugku login1
[BJDCTF2020]Easy MD5
Bugku login1
Pat grade a 1046 shortest distance
Question collection come and ask nllb authors! (Zhiyuan live issue 24)
C#事件和委托的区别
【万字长文】使用 LSM-Tree 思想基于.Net 6.0 C# 实现 KV 数据库(案例版)
Pat grade a 1044 shopping in Mars
Re7:读论文 FLA/MLAC Learning to Predict Charges for Criminal Cases with Legal Basis
TKE集群节点max-pod是如何配置的
互联网协议
The difference between oncreate and onrestoreinstancestate recovery data of activity
Summary of key knowledge of C language
[ten thousand words long text] Based on LSM tree thought Net 6.0 C # realize kV database (case version)
Difference between C event and delegation
JS API summary of Array Operations
2022年全国最新消防设施操作员(高级消防设施操作员)考试试题及答案
面试时候常说的复杂度到底是什么?