微信小程序wx.request POST獲取不到數據解決辦法


get

    //發起請求

    wx.request({
      url: 'http://www.xiaochengxu.com/home/index/curd', //僅為示例,並非真實的接口地址
      method:'GET',
      data: {
        title: '123',
        content: '456'
      },
      header: {
        'content-type': 'application/json'
      },
      success: function (res) {
        console.log(res.data)
      }
    })
 
 
post
    //發起請求
    wx.request({
      url: 'http://www.xiaochengxu.com/home/index/curd', //僅為示例,並非真實的接口地址
      method:'POST',
      data: {
        title: '123',
        content: '456'
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        console.log(res.data)
      }
    })
 
解決辦法:修改headder里面的屬性值。


免責聲明!

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



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