Issue with sending data using WP REST API
-
I am using Contact Form 7 on my WordPress site and trying to send data to it using the WP REST API from my Next.js app. I am sending a POST request to the URL https://my-site.com/wp-json/contact-form-7/v1/contact-forms/369/feedback but I am receiving a “mail_sent” status and “Thank you for your message. It has been sent.” message as a response, but the email that I receive has no data.
I have verified that the values of the form fields are correctly being passed to the FormData object and the request headers and body are also fine. But the email received is still empty.
This is my function for sending POST request:
const handleSubmit = async (e) => { e.preventDefault(); validateName(name) && validateEmail(email) && validateMessage(message); if ( formIsValid && nameError === null && emailError === null && messageError === null ) { try { let formData = new FormData(); formData.append("your-name", name); formData.append("your-email", email); formData.append("your-message", message); for (const [key, value] of formData.entries()) { console.log(key, value);//when i console.log this, i see key value pairs in console } const response = await fetch(
https://my-site.com/wp-json/contact-form-7/v1/contact-forms/369/feedback
, { method: "POST", headers: { "Content-Type": "multipart/form-data", }, body: formData, } ); } catch (error) { console.error(error); } } else { console.log("form is not valid"); } };Can you please take a look and let me know what might be causing this issue?
Thank you.
- The topic ‘Issue with sending data using WP REST API’ is closed to new replies.