After the user hits the ‘Submit’ button of a form, we may want to perform some server-side validation which involves checking our database to evaluate the validity of our form.
Hi, How to avoid double entry of data when there is network issue or some other issue like user clicking a lot of times and creates same form many times? Thanks
const onSubmit = async(values)=>{ const data = {service, email};
const response = await axios({
method: 'post',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
//url: 'https://wwww.afghanconsulate-munich.com/terminserver/sendemail.php',
url: config.apiEndPoint+'/hasactiveappointment.php',
data: data
});
if(response.data ==="exist"){
throw new SubmissionError({
service: "You have already an active appointment for this service!"
})
}
else
handleSubmit();
}
regardless of what i get from sever, it does not process further when i click submit
Hi @Rory Smith, Could you please help me with my code. i check in the mysql table if a record with that email and service exists, if yes, i return exist if not i return notExist, but i when i receive it via response.data , my condition does not work ad expected