I’m working on connecting my contact form to Airtable’s API but keep running into issues. When I submit the form, I get this error message: {"error":{"type":"INVALID_REQUEST_MISSING_FIELDS","message":"Could not find field \"fields\" in the request body"}}
I’m pretty new to JavaScript and Airtable integration, so I might be missing something basic. Using React with axios for the API calls.
var contactForm = document.querySelector("#contact-form");
if(contactForm) {
contactForm.addEventListener("submit", function(e) {
e.preventDefault();
axios.post(airtable_api_url,
{
"Content-Type": "application/json"
},
{
"fields": {
"FullName": document.getElementById("#full-name"),
"EmailAddress": document.getElementById("#user-email"),
"PhoneNumber": document.getElementById("#phone"),
"Subject": document.getElementById("#message-subject"),
"MessageText": document.getElementById("#user-message"),
"Source": "Website"
}
})
.then(function(result) {
console.log(result);
})
.catch(function(err) {
console.log(err);
})
})
};
What am I doing wrong with the request structure? Any help would be great!