axios 请求数据,返回数据 data为空
同样的借口用jq的ajax调用就是好的
$.ajax({
url: '/yzh/inter/login',
type: 'post',
data: {'userName': username, 'passWord': password},
success: function (res) {
console.log(res);
}
});
下边是axios的发送
var config = {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
responseType: 'json',// default
method: 'post'
};
axios.post('/yzh/inter/login', {
userName: this.ruleForm.username,
passWord: this.ruleForm.password
},config)
.then((res) => {
//if (res) {
//state.username = res.data.data
console.log("haha",res)
// }
})
返回结果中 data为null
请问这个问题怎么解决啊。。
伊谢尔伦2017-04-17 16:39:47
Try to analyze on the server side and print out the received parameters to see if they are consistent
高洛峰2017-04-17 16:39:47
It may be a problem with the post parameters of axios. Refer to axios POST
黄舟2017-04-17 16:39:47
https://www.npmjs.com/package...
The default post request is to send data in json format