Hey there,
I am using netlify-forms in my Nuxtjs app. I am submitting the form using fetch()
from /contact
page.
Here is my JS code.
let data = {
name: this.name,
email: this.email,
subject: this.subject,
message: this.message,
"form-name": "contact"
};
fetch("/contact", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"
},
body: this.encode(data)
})
.then(data => console.log(data))
.catch(err => console.error(err));
The encode function from here.
encode (data) {
return Object.keys(data)
.map(
key => `${encodeURIComponent(key)}=${encodeURIComponent(data[key])}`
)
.join("&");
}
I am getting 304 status and the form is not submitting.
Please help!