post請求報錯:
status:failed
方法1:
安裝qs
npm install qs
api:
config.headers['Content-Type'] = 'application/json'
zujian.vue:
import qs from 'qs'
let param={
postCode:this.$route.query.pc,
}
requestReplypost(qs.parse(param)).then(response=>{
this.postList.push(response)
this.contp=''
})
方法2:
api.js:
axios.defaults.headers['Content-Type'] = 'application/json';
zujian.vue:
(get,post傳參形式不同)
let param={
phoneNo:this.phoneNo,
captcha:this.captcha
}
this.$http({
method:'post',
url:'http://xx.x.x.x:8600/god/capt',
headers:{
'Content-Type':'application/json'
},
data:JSON.stringify(param)
}).then((res)=>{
document.getElementById("btnp").disabled=false;
let sss=res.data})
this.$http({
method:'get',
url:'http://xx.x.x.x:8600/god/Inout?residentID='+this.residentID+'&type='+this.type,
headers:{
'Content-Type':'application/json'
},
// data:JSON.stringify(param)
}).then((res)=>{
let data=res.data})