微信小程序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