中三A105论坛

注册 登录
查看: 936|回复: 1

微信小程序的POST和GET请求方式的header区别

[复制链接]

105

主题

119

帖子

553

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
553
发表于 2018-7-15 16:16:08 | 显示全部楼层 |阅读模式
1.post请求:
wx.request({

        url: 'https://m.***.com/index.php/Home/Xiaoxxf/make_order',

        header: {

          "Content-Type": "application/x-www-form-urlencoded"

        },

        method: "POST",

        data: { is_home: that.data.is_home, openid: wx.getStorageSync('openid'), data_name: e.detail.value.data_name },
      success: function (res) {
       //...
     
   }
})
2.GET请求

wx.request({
    url: 'https://m.***.com/index.php/Home/Xiaoxxf/getStory',
    data: {
      page: page
    },
    method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT  
    // header: {}, // 设置请求的 header  
    header: {
      'Content-Type': 'application/json'
    },
    success: function (res) {
      console.log(res.data)
      that.setData({
        list: res.data          //返回二维数组
        // views: res.data[0].views,     //查看数
        // praise: res.data[0].praise    //点赞数
      })
      page++;
    }
})


回复

使用道具 举报

105

主题

119

帖子

553

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
553
 楼主| 发表于 2018-7-15 16:16:35 | 显示全部楼层
测试过,可以使用
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回列表 返回顶部