Home > Article > WeChat Applet > How to solve the problem of request 400 in WeChat applet
对于header['content-type'] 为application/json 的数据,会对数据进行json序列化 对于header['content-type'] 为 application/x-www-form-urlencoded 的数据,会哦将数据转换成query string (encodeURIComponent(k)=encodeURIComponent(v)&encodeURIComponent(k)=encodeURIComponent(v)...)
The following is my WeChat account List of codes in the program
//请求URL wx.request({ url:"https://api.douban.com/v2/movie/top250", data:{}, header: { 'content-type': 'application/json' // 默认值 }, success:function(res){ wx.hideToast(); console.log(res.data); } });
The following are the errors that occur after compilation
I modified the header in the request as follows:
header: { //'content-type': 'application/json' // 默认值 //这里修改json为text json的话请求时会返回400(bad request) 'content-type': 'application/texts' },
After modification, debugging is as follows
The above is the detailed content of How to solve the problem of request 400 in WeChat applet. For more information, please follow other related articles on the PHP Chinese website!