【发布时间】:2021-11-24 08:20:47
【问题描述】:
每当我使用 Vue.js (3.x) 发送 POST 请求时,都会使用 HTTP 状态代码 204 和“预检”类型向同一 URL 发出附加请求。
这是什么预检请求,我该如何解决它,以免它作为重复发送?
Register.vue
async submit() {
this.button = true;
try {
const response = await axios.post(`register`, this.form);
if(response.data.success == false)
{
console.log(response.data.message);
}
else
{
this.$router.push('/');
}
}
catch (error)
{
let { errors } = error.response.data;
this.button = false;
this.errors = {};
Object.keys(errors).forEach(element => {
this.errors[element] = errors[element][0];
});
}
},
【问题讨论】:
标签: vue.js post axios cors preflight