微信小程序https发起请求失败的解决方法

https://blog.csdn.net/yuhui123999/article/details/60572888

https://blog.csdn.net/yuhui123999/article/details/60572888

https://blog.csdn.net/yuhui123999/article/details/60572888

微信小程序中wx.request是发起的是HTTPS 请求,其method有两种方法:get和post。

method为get时,header必须为:

  1. header: {

  2. \'content-type\': \'application/json\'

  3. },

method为post时,header必须为:

  1. header: {

  2. \'content-type\': \'application/x-www-form-urlencoded\'

  3. },

如果header错误会导致后台得不到数据而报NullPointerException错误