uniapp請求,使用x-www-form-urlencoded報錯
阿新 • • 發佈:2020-12-12
技術標籤:筆記javascriptuni-app
uni.request({
url: '',//被我刪了介面
header: {
'content-type': 'application/x-www-form-urlencoded'
},
method:'POST', //請求方式
data:that.loginData,
success: function(res) {
console.log(res)
}
})
一直報錯500。
因為介面需要使用x-www-form-urlencoded,查了好久,才發現是這個header的問題。
header要放在前面,修改一下位置。
uni.request({
header: { 'content-type': 'application/x-www-form-urlencoded'},
url: '',//被我刪了介面
method:'POST', //請求方式
data:that.loginData,
success: function(res) {
console.log(res)
}
})
200成功
如果本文幫助到你或對你有啟發,點個贊再走唄