Home > Article > WeChat Applet > WeChat applet network request (post request, get request)
This article mainly introduces the relevant information about WeChat Mini Program network requests (post requests, get requests). Friends in need can refer to
WeChat Mini Program Network Requests
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( '网络请求失败' ); 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' }, // 设置请求的 header success: function(res){ that.data.items= res.data }, fail: function() { // fail }, complete: function() { // complete } }) }
Thank you for reading, I hope it can help you, thank you for your support of this site!
For more WeChat applet network request (post request, get request) related articles, please pay attention to the PHP Chinese website!