Hi guys,
I am a little frustrated here and need some help. I have been trying to figure out how to write webhooks as I want to send database information via a webhook to Zapier and use the data for other services.
Is there anyone in the community who would want to help me out? I am based in New Zealand.
and then if you have a button or whatever try this code and modify for your project, it’s working to send whatever you want to Zapier.
function sendButton_click(event,$w){
//When the send button has been clicked we need to post the forms data to Zapier
consturl="yourzapierwebhookaddresshere/";
letfrom=$w("#from").value;
letto=$w("#to").value;
letsubject=$w("#subject").value;
letmessage=$w("#message").value;
letdata={"from":from,"to":to,"subject":subject,"message":message};
console.log(data);
varbodyData=JSON.stringify(data);
fetch(url,{method:'post',body:bodyData})
.then((httpResponse)=>{
if(httpResponse.ok){
returnhttpResponse.json();
}else{
returnPromise.reject("Fetchdidnotsucceed");
}
})
.then(json=>{
console.log(JSON.stringify(json));
$w("#sendButton").disable();
$w("#sendButton").label="Thanks for submitting the data!";
})
.catch(err=>console.log(err));
}
Hmmmmmm I really don’t know what I am doing…I dont know what to edit or where to place the code haha. Wix should give you a comission for every time you help someone though!
let firstName = $w(“#firstName”).value;
let lastName = $w(“#lastName”).value;
let contactEmail = $w(“#contactEmail”).value;
let contactCompany =$w (“#contactCompany”).value;
let contactNumber = $w(“#contactNumber”).value;
let contactStaffN = $w(“#contactStaffN”).value;
let contactComments = $w(“#contactComments”).value;
let data = {
“firstName”:firstName,
“lastName”:lastName,
“contactEmail”:contactEmail,
“contactCompany”:contactCompany,
“contactNumber”:contactNumber,
“contactStaffN”:contactStaffN,
“contactComments”:contactComments
};
console.log(data);
varbodyData=JSON.stringify(data);
fetch (url,{method:'post',body:bodyData})
.then((httpResponse)=>{
if(httpResponse.ok){
returnhttpResponse.json();
}else{
returnPromise.reject("Fetchdidnotsucceed");
}
})
.then(json=>{
console.log(JSON.stringify(json));
$w("#button1").disable();
$w("#button1").label="Thanks for submitting the data!";
})
.catch(err=>console.log(err));
}
I keep getting error messages from Wix though so could you or someone else be able to point out what I am doing wrong! Thanks
Wow two replies on your course and here! Wix, take note of Andreas’s customer service.
I am the same guy who wrote on your ‘send data to google sheets’ course so maybe we just stick to one source on your course comment thread otherwise we might get confused!