Skip to content

Form submission not working #51

Answered by lilyntalmers
lilyntalmers asked this question in Q&A
Discussion options

You must be logged in to vote

Thank you Ivan, It worked. I just had to modify the code a little bit. I am writing down the changes I made so it can helpful to anyone who is facing the same problem.

  const handleSubmit = (values) => {
    console.log(values)
    fetch(`https://formsubmit.co/ajax/lilyntalmers@gmail.com`, {
      method: "POST",
      // Udpate the headers here ⬇️
      headers: { 
        'Content-Type': 'application/json',
        'Accept': 'application/json'
      },
      body: JSON.stringify({
         name: `From ${values?.email || 'no email'}`,
         message: JSON.stringify(values, null, 2),
      }),
    })
      .then((data) => {
        console.log(data);
        alert("Success");
      })
…

Replies: 2 comments 10 replies

Comment options

You must be logged in to vote
9 replies
@lilyntalmers
Comment options

@ivan-dalmet
Comment options

@ivan-dalmet
Comment options

@lilyntalmers
Comment options

@ivan-dalmet
Comment options

Comment options

You must be logged in to vote
1 reply
@ivan-dalmet
Comment options

Answer selected by lilyntalmers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants