微信小程序wx.request的POST方法的参数传输服务器接收不到的bug

微信 小程序 2117      收藏
微信小程序wx.request的POST方法的参数传输服务器接收不到的bug

wx.request post 的 content-type 默认为 'application/json'

   如果服务器没有用到 json 解释的话,可以把 content-type 设置回 urlencoded。

   

wx.request({

  url: app.url + 'signup/2',

  data: {

    username: username,

    telephone: telephone

  },

  method:'POST',

  header: {

    // 'Content-Type': 'application/json'

    "content-type": "application/x-www-form-urlencoded"

  },

  success: function (res) {

    console.log(res.data);

  },

  complete: function () {


 }

})


终于可以post提交了,大家不要按照官网的文档写,也不用转格式,修改header即可。

自学php博客