wx.request({
url: 'test.php', //仅为示例,并非真实的接口地址
data: {
x: '',
y: ''
},
header: {
'content-type': 'application/json' // 默认值
},
success (res) {
console.log(res.data)
}
fail: function (res) {
console.log('Fail to request !')
console.log(res)
}
})
1.url: the url address of the server 2.header
(request header) The
content-type defaults to application/json.
For data whose header['content-type'] is'application/json', the data will be JSON serialized.
For header ['content-type'] is the data of'application/x-www-form-urlencoded', the data will be converted into query string