I defined a mock login request in a component of Vue. I defined the login user name and password in userinfo under data in advance.
the following is a defined code snippet:
import axios from "axios"
export default {
name:"MainViews",
data () {
return {
userinfo:{
username:"admin",
password:"wt_adam110"
}
}
},
created () {
this._getuser ()
},
methods: {
_getuser () {
axios({
method: "post",
url: "/apis/jxue/a/login",
data: postData,
headers: {
"Content-Type":"application/x-www-form-urlencoded"
}
}).then((res)=>{
console.log(res);
})
}
}
}
after completing the above simulation, type the result to me on the console:
:
POSTQs.stringfy()
npm install qs --save
import qs from "qs"
:
:
in config/index.js, I have done cross-domain processing. The server I interface to is on another machine in my local area network.)
proxyTable: {
"/apis": {
target: "http://192.168.31.177:8080", //
// secure: true, // https
changeOrigin: true, //
pathRewrite: {
"^/apis": "" //
}
}
}
this is the whole situation. I have two questions:
- Why can"t my POST data return normal data? is there something wrong with the data when I request it? How to solve it?
- Why do I have cross-domain problems after I change the format of the POST parameter?