微信小程序的POST和GET請求方式的header區別


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++;
    }
 })

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM