微信小程序post请求服务器接收不到参数

这个坑真深…

一开始去请求线上接口,老是爆传的数据为空。刚开始怀疑写的方法有错,检查没错后,上服务器打印传过来的进日志,发现日志接受到参数为空,懵逼。

原来是wx.request默认header头部为:

 headers: {
      'Content-Type': 'application/json'
    },

这种模式对于原来接口不能接收,后改为:

 header: {
          'content-type': 'application/x-www-form-urlencoded'
        },

截图:

正常接收到参数…

猜你喜欢

转载自blog.csdn.net/li_xue_zhao/article/details/84553265