我在 Formik 中使用 axios post 请求,return me 400 错误
i'm using axios post request in Formik,and return me 400 error
enter image description here
请查看img,我尝试使用它,但它不起作用,我不明白为什么
<Formik
initialValues={{email: "", password: "", firstname: "",
lastname: "", passwordConfirm: ""}}
onSubmit={(values, {setSubmitting}) => {
console.log(values);
// Send a POST r`enter code here`equest
axios.post('http://212.42.212.29:3001/auth/register', values, {
"headers": {
"content-type": "application/json",
}
}).then(function (response) {
console.log(response);
}).catch(function (error) {
console.log(error.response);
});
}}
>
我的错误在Formik,我写错了值名
<Formik
initialValues={{email: "", password: "", firstname: "", lastname: "",
passwordConfirm: ""}}
>
**应该是**
<Formik
initialValues={
{email: "",
password: "",
**firstName: "",**
**lastName:""**,
passwordConfirm: ""}}
>
enter image description here 请查看img,我尝试使用它,但它不起作用,我不明白为什么
<Formik
initialValues={{email: "", password: "", firstname: "",
lastname: "", passwordConfirm: ""}}
onSubmit={(values, {setSubmitting}) => {
console.log(values);
// Send a POST r`enter code here`equest
axios.post('http://212.42.212.29:3001/auth/register', values, {
"headers": {
"content-type": "application/json",
}
}).then(function (response) {
console.log(response);
}).catch(function (error) {
console.log(error.response);
});
}}
>
我的错误在Formik,我写错了值名
<Formik
initialValues={{email: "", password: "", firstname: "", lastname: "",
passwordConfirm: ""}}
>
**应该是**
<Formik
initialValues={
{email: "",
password: "",
**firstName: "",**
**lastName:""**,
passwordConfirm: ""}}
>