【发布时间】:2022-01-03 16:51:26
【问题描述】:
我遇到了一个错误:
422 (Unprocessable Content)
当我尝试在注册表中发布数据时
我的 Register.vue 中有这个
methods: {
register() {
this.$store.dispatch('register', {
firstname: this.firstname,
lastname: this.lastname,
email: this.email,
password: this.password,
});
},
},
};
在我的 vuex 中
actions: {
register(credentials) {
const requestOptions = {
method: 'POST',
headers: { 'content-type': 'application/json' },
dataType: 'json',
body: JSON.stringify(credentials),
};
console.log(credentials);
return fetch('http://localhost/api/users', requestOptions)
.then((response) => {
return response.json;
})
.catch((err) => console.log(err.message));
},
}
有人知道我错在哪里吗? 非常感谢
【问题讨论】: