get
//發起請求
wx.request({
url: 'http://www.xiaochengxu.com/home/index/curd', //僅為示例,並非真實的接口地址
method:'GET',
data: {
title: '123',
content: '456'
},
header: {
'content-type': 'application/json'
},
success: function (res) {
console.log(res.data)
}
})
post
//發起請求
wx.request({
url: 'http://www.xiaochengxu.com/home/index/curd', //僅為示例,並非真實的接口地址
method:'POST',
data: {
title: '123',
content: '456'
},
header: {
'content-type': 'application/x-www-form-urlencoded'
},
success: function (res) {
console.log(res.data)
}
})
解決辦法:修改headder里面的屬性值。