axios请求400错误解决方案

前端请求头的content-type和后端不一致,导致请求失败

var params = new URLSearchParams();

params.append('password', '123');

params.append('phone', '123');

this.$axios({

method: "post",

url: "https://back.zhanchengwlkj.com/jikang/login",

headers:{

'Content-type': 'application/x-www-form-urlencoded'

},

data: params,

}).then((res) => {

console.log(res.data);

})

你可能感兴趣的:(axios请求400错误解决方案)