axios post 请求中未传递数据
Data not passing in axios post request
我正在使用 axios
调用 post 请求,如下所示:
axios.post(this.api+'&action='+this.action+'&wftkn='+this.wftkn, {name: 'Abcd'}).
then((res)=>{
});
当我检查网络选项卡时,我没有看到请求中传递的数据 header。在这种情况下会出现什么问题?
编辑:添加了控制台错误。
请试试这个:
axios.post(this.api, { name: 'Abcd' }, {
params: {
action: this.action,
wftkn: this.wftkn,
}
}).then((res)=>{});
这是浏览器的一种保护,你在不同的域上请求资源,所以你需要设置一个响应头:
Access-Control-Allow-Origin: http://localhost:8000
https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS
我正在使用 axios
调用 post 请求,如下所示:
axios.post(this.api+'&action='+this.action+'&wftkn='+this.wftkn, {name: 'Abcd'}).
then((res)=>{
});
当我检查网络选项卡时,我没有看到请求中传递的数据 header。在这种情况下会出现什么问题?
请试试这个:
axios.post(this.api, { name: 'Abcd' }, {
params: {
action: this.action,
wftkn: this.wftkn,
}
}).then((res)=>{});
这是浏览器的一种保护,你在不同的域上请求资源,所以你需要设置一个响应头:
Access-Control-Allow-Origin: http://localhost:8000
https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS