Apr 6, 202110:27 AM - edited Apr 6, 202110:28 AM
Key Advisor
Submited forms POST to a third party API via module
HI @dennisedson, you took the words from my fingers, as it were. Sending data via POST usually requires some form of authentication, which you can put in your client side JS but I would advise against it for security reasons. Google Cloud functions and AWS Lambda both have free tiers (up to 2 million and 1 million/month executions respectively, and some number of GB-seconds that I can't remember).
As @dennisedson has said, generally speaking using the Hubspot Form methods like onFormSubmit would work well for this, alternatively using the Hubspot Form message event
window.addEventListener('message', event => {
if(event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormSubmit') {
// do something (you could also add the form id in the above if statement if you want it for a specific form)
}
});
We need more info on the API you want to use to be able to provide more specific help.
Might need more details on the the third party API. For one, does it require some form of authentication such as an API key? If so, some form of middleware may be necessary. There is an onformsubmit callback function that might be of use to you here.