A 400 error occurs in the small program request.
Solution to 400 Error in small program request
I recently followed the demo to learn the applet. When I made a network request, I encountered 400 errors. The Code is as follows:
Wx. request ({url: "https://api.douban.com/v2/movie/top250", data :{}, header: {"Content-Type": "application/json"}, success: function (res) {console. log (res. data); var data = res. data; currentPage. setData ({list: data. subjects })},});
In the following situations, I was also scared (the browser can also take data ):
It turns out that after the development tool upgrade, the Content-type method of the Request header has changed (the development tool Version I am currently using is 0.14) and needs to be changed
Header: {"Content-Type": "json "},
In this way, you can request data normally.
Thank you for reading this article. I hope it will help you. Thank you for your support for this site!