Hi, hoping someone can help me post form data to an external API. This is the demo contact form method from the gatsby-starter-netlify-cms which handles the submission:
handleSubmit = e => {
e.preventDefault()
const form = e.target
fetch('/', {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: encode({
'form-name': form.getAttribute('name'),
...this.state,
}),
})
.then(() => navigate(form.getAttribute('action')))
.catch(error => alert(error))
}
I’ve set the action of the form to https://crm.zoho.eu/crm/WebToLeadForm however, the form is posting to http://localhost:8000/https:/crm.zoho.eu/crm/WebToLeadForm
<form
name="WebToLeads"
method="post"
action="https://crm.zoho.eu/crm/WebToLeadForm"
data-netlify="true"
data-netlify-honeypot="bot-field"
onSubmit={this.handleSubmit}
Is this when you test locally or in production? If it’s up and running, could you please share a link to your Netlify URL so we can take a look? If it’s local, I would try pushing to Netlify to see if works there- there might be a local dev step that is prepending localhost to your form action but won’t in production.