简体   繁体   English

我在 Formik 中使用 axios post 请求,并返回 400 错误

[英]i'm using axios post request in Formik,and return me 400 error

enter image description here pleas look at img,i try to use it , but its dosent work, and i cant understand why请在此处输入图像描述,请查看 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);
            });

    }}
  
>

My mistake was in Formik, I have written value names mistakenly我的错误是在 Formik 中,我写错了值名称

   <Formik 
     initialValues={{email: "", password: "", firstname: "", lastname: "", 
       passwordConfirm: ""}}
     >

**should be ** **应该 **

   <Formik 
    initialValues={
          {email: "", 
           password: "", 
         **firstName: "",** 
         **lastName:""**, 
     passwordConfirm: ""}}
   >

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM