Home  >  Article  >  WeChat Applet  >  Detailed explanation of the network request API of WeChat mini program

Detailed explanation of the network request API of WeChat mini program

高洛峰
高洛峰Original
2017-03-11 14:16:442274browse

This article mainly introduces the relevant information on the detailed explanation of the WeChat applet network request API. Friends in need can refer to

wx.request (OBJECT) initiates an https request. A WeChat applet can only have 5 network request connections at the same time.

OBJECT parameter description:

Rendering:

net.js


Page({
 data:{
  result:{},
 },
 onLoad:function(options){
  this.getDate('http://baobab.wandoujia.com/api/v2/feed?num=2');
 },
 /**
  * 网络请求的函数:接收一个URL参数
  */
 getDate:function(URL){
    var that = this; 
    // 申请一个网络请求
      wx.request({
    url:URL,
    method:'GET',
   //添加data
   // data: {
   //  x: '',
   //  y: ''
   //  },
   //添加头信息
   // header: {
   //  'Content-Type': 'application/json'
   // },
    // 请求成功的回调
    success: function(res) {
      that.setData({
        result:res.data
      })
      console.log(res.data)
    }
    })
 },
})

net.wxml:


<block wx:for-items="{{result.issueList}}">
  <Text style="color:green;">第{{index+1}}个列表</Text>
  <block wx:for-items="{{item.itemList}}">
     <image style="width:100%;height:200px;" src="{{item.data.cover.feed}}"></image>
  </block>
</block>

Thank you for reading, I hope it can help everyone, thank you for your support of this site support!

The above is the detailed content of Detailed explanation of the network request API of WeChat mini program. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn