This article mainly introduces information about small program network requests (post requests, get requests). For more information about small program network requests (post requests, for more information about get requests, see
Applet network request
1. post request:
OnLoad: function () {that = this; wx. request ({url: "url", header: {"Content-Type": "application/x-www-form-urlencoded"}, method: "POST", data: {}, complete: function (res) {console. log (res. data)}); if (res = null | res. data = null) {console. error ('network request failed'); return ;}}})},
2. GET request
OnLoad: function () {console. log ('onload') var that = this wx. request ({url: 'http: // json.bmbstack.com/cinemaList', data: {}, method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT header: {'accept': 'application/json'}, // Set the request header success: function (res) {that. data. items = res. data}, fail: function () {// fail}, complete: function () {// complete }})}
Thank you for reading this article. I hope it will help you. thank you for your support for this site!
For more articles on small program network requests (post requests, get requests), please follow PHP Chinese network!