I am trying to serialize an array for inputs in the Hubspot form to add or change cookies, but I keep getting the error onFormReady function from hbspt.forms.create TypeError: e.serializeArray is not a function and I don't know what to do. I am trying to not use jQuery, what can I use to replace it?
<script>
hbspt.forms.create({
region: "",
portalId: "",
formId: "",
redirectUrl: "/thank-you/",
onFormReady: function(e){
e.serializeArray().map(x=>{
let cookie_val = Cookies.get(x.name)
if (cookie_val && cookie_val != ''){
e.find('input[name="'+x.name+'"]').val(cookie_val).change();
}
})
}
});
</script>
According to docs,
onFormReadyreturnsformobject. It is not an array, so you can try to serialize inputs: