当前位置:网站首页>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 ”.
边栏推荐
- vlang捣鼓之路
- 结构体和类使用的区别
- The process and harvest of developing browser plug-ins with clojurescript
- Replicationcontroller and replicaset of kubernetes
- Activity之onCreate、onRestoreInstanceState恢复数据的区别
- C#读取本地文件夹中所有文件文本内容的方法
- 数字化转型怎么就那么的难?!
- Operating system migration practice: deploying MySQL database on openeuler
- 国元期货网上开户安全吗?开户办理流程是怎样的?
- Happy 10th birthday, clojure
猜你喜欢

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

The difference and efficiency comparison of three methods of C # conversion integer

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

Advanced CAD exercises (I)

Nacos win10 安装配置教程

vlang捣鼓之路

Bugku login2

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

我的sql没问题为什么还是这么慢|MySQL加锁规则

Collection of open source expert opinions on trusted privacy computing framework "argot"
随机推荐
Vscode batch delete
Compiler analysis of clojure operation principle
Botu PLC Sequential switch function block (SCL)
C # method to read the text content of all files in the local folder
Clojure 运行原理之编译器剖析
Class initialization mechanism of JVM
Clojure 运行原理之字节码生成篇
Modify the password of the root user of MySQL database
PAT甲级 1050 String Subtraction
JVM 的类初始化机制
操作系统迁移实战之在openEuler上部署MySQL数据库
Alibaba cloud DMS MySQL cloud database report error, solve!!
Reflections on the mystery of Silicon Valley
The difference and efficiency comparison of three methods of C # conversion integer
2022年最新北京建筑安全员模拟题库及答案
C#事件和委托的区别
First knowledge of OpenGL (2) compilation shaders
NUC 11 build esxi 7.0.3f install network card driver-v2 (upgraded version in July 2022)
Build resume editor based on Nocode
Comprehensively design an oppe homepage -- the design of the top and head