I am looking to design my own form on my website that allows a user to put in data (Name, Address, DOB & Contact Number etc) That will go into a database. What I am looking to do is set up a Post Request on my form that will automatically send the details to my CRM system. I have some understanding and have set up post requests before (With the use of some automated software) but I am struggling with it. Can anyone help?
Hey,
You can create an onClick event on the submit button and use the fetch API to post information to your CRM system:
import {fetch} from 'wix-fetch';
export function submitBtnId_onClick(event, $w) {
//Add here the URL of the CRM API , the method type is "post"
fetch('https://api.fixer.io/latest', {method: 'post'})
.then( (httpResponse) => {
if (httpResponse.ok) {
return httpResponse.json();
} else {
return Promise.reject("Fetch did not succeed"); }
} )
.catch(err => console.log(err));
}
I’m trying to send the form Data to google Sheets but it is not working. On my Google Sheet Script Editor i can see that the Web App is being called every time the submit button is clicked but nothing is posted.