const SignUpForm = () => {
const {values ,errors , handleChange , handleSubmit} = useFormik({
initialValues ,
validationSchema: SignupSchema,
onSubmit : async ()=>{
const user = await fetch('http://localhost:8080/user/register' ,{
method : "POST" ,
body : JSON.stringify(values)
})
console.log(user ,values);
}
})
const router = express.Router()
router.use(bodyParser.urlencoded({extended : false}))
router.use(express.json())
router.post('/register' , async(req,res)=>{
console.log(req.body);
res.json({
message : 'success'
})
})
I am trying to get form values in server , but it’s returning me an empty object. is there any issue with post request? . I have tried everything I know but its not working .
2
Answers
please do the below change and check
Write below code:
Instead of
@KASHi Try below code :
I tried above It’s working. compare with your code, if still not works then paste your whole server js file here so I can help