node.js - axios 请求数据,返回数据 data为空怎么办
巴扎黑
巴扎黑 2017-04-17 16:37:47
0
4
1035

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

请问这个问题怎么解决啊。。

巴扎黑
巴扎黑

reply all(4)
黄舟

I guess there’s something wrong with the writing

伊谢尔伦

Try to analyze on the server side and print out the received parameters to see if they are consistent

小葫芦

It may be a problem with the post parameters of axios. Refer to axios POST

黄舟

https://www.npmjs.com/package...
The default post request is to send data in json format

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template