问题:用post请求方式时,后端接受不到前端传回的数据,而用get方式可以。
原因:微信小程序api,默认使用的get方式。
前端代码按照文档,肯定是这么写.那就入坑了.
header头中: 'Content-Type': 'application/json'用在get请求中没问题.
POST请求就不好使了.需要改成: "Content-Type": "application/x-www-form-urlencoded"
wx.request( {
url: "http://op.juhe.cn/onebox/weather/query",
header: {
"Content-Type": "application/x-www-form-urlencoded"
},
method: "POST",