当前位置:网站首页>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 ”.
边栏推荐
- 互联网协议
- The process and harvest of developing browser plug-ins with clojurescript
- Tao and art of R & D Efficiency - Tao chapter
- Linux安装mysql8.0.29详细教程
- FTP协议
- 该怎么写单元测试呢
- 量化交易之数字货币篇 - 通过时间戳与方向来合并逐笔成交数据(大单合并)
- MVC和ECS两种设计架构的初浅理解
- [ten thousand words long text] Based on LSM tree thought Net 6.0 C # realize kV database (case version)
- Sword finger offer special assault edition day 11
猜你喜欢

PAT甲级 1045 Favorite Color Stripe

2022年最新北京建筑安全员模拟题库及答案
![[physical simulation] the principle and practice of the simplest shape matching](/img/1e/d91ed992bc648d90d0c68bfe541d7e.jpg)
[physical simulation] the principle and practice of the simplest shape matching

综合设计一个OPPE主页--导航栏的设计

Pat grade a 1050 string subtraction

The difference between anonymous methods and lambda expressions

终于有人把红蓝对抗讲明白了

Comprehensively design an oppe homepage -- Design of star models

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

ACL-IJCAI-SIGIR顶级会议论文报告会(AIS 2022)笔记3:对话和生成
随机推荐
NUC 11 build esxi 7.0.3f install network card driver-v2 (upgraded version in July 2022)
The "nuclear bomb level" log4j vulnerability is still widespread and has a continuing impact
Summary of key knowledge of C language
6种方法帮你搞定SimpleDateFormat类不是线程安全的问题
Re9:读论文 DEAL Inductive Link Prediction for Nodes Having Only Attribute Information
Comprehensive design of an oppe homepage -- Design of navigation bar
Question collection come and ask nllb authors! (Zhiyuan live issue 24)
Pat grade a 1045 favorite color stripe
Pat class a 1047 student list for course
kubernetes之ReplicationController与ReplicaSet
JVM 的类初始化机制
Activity之onCreate、onRestoreInstanceState恢复数据的区别
结构体和类使用的区别
【万字长文】使用 LSM-Tree 思想基于.Net 6.0 C# 实现 KV 数据库(案例版)
PAT甲级 1044 Shopping in Mars
【物理模拟】最简单的shape matching的原理与实践
Linux安装mysql8.0.29详细教程
PAT甲级 1049 Counting Ones
Botu PLC Sequential switch function block (SCL)
TKE集群节点max-pod是如何配置的