Hi guys,
I conntected a custom form on my page to zapier via a webhook, in order to then write an email with the data in zapier.
Everything is working fine actually, exept that the webhook is triggering the zap 2 times.
I checked it in the console and it also logs 2 times, so the issue must be in the code i guess.
This is the console log:
{"id":"d26bd75b-06ca-4ed9-a274-0bf2d9c5d376","request_id":"6125e2f1-87ef-4f48-889a-ab6a96ef78e0","attempt":"6125e2f1-87ef-4f48-889a-ab6a96ef78e0","status":"success"}
workerLogger.js:103
{"id":"106526b9-d90f-4a3e-944e-d1bf9e9b3672","request_id":"6125e2f1-7b61-4e52-a828-9f6323a46fc0","attempt":"6125e2f1-7b61-4e52-a828-9f6323a46fc0","status":"success"}
workerLogger.js:103
This is the code:
//Zapier Hook
const url = "https://hooks.zapier.com/hooks/catch/10251821/bunylut/";
let datum = $w("#datePicker1").value;
let beschreibung = $w("#textBox1").value;
let budget = $w("#dropdown2").value;
let projekt = $w("#radioGroup1").value;
let artdesauftrags = $w("#radioGroup2").value;
let contentverwaltung = $w("#dropdown4").value;
let data2 = {
"beschreibung": beschreibung,
"datum": datum,
"budget": budget,
"artdesauftrags": artdesauftrags,
"contentverwaltung": contentverwaltung,
"projekt": projekt,
"vorname": $w("#input1").value,
"nachname": $w("#input2").value,
"email": $w("#input3").value,
"agenturname" : itemData.title,
"agenturemail" : itemData.eMail,
"agenturvorname" : itemData.vorname,
"agenturnachname" : itemData.nachname,
};
var bodyData = JSON.stringify(data2);
fetch(url, {method: 'post', body: bodyData})
.then ((httpResponse)=>{
console.log("post succesful");
if(httpResponse.ok){
return httpResponse.json();
}else{
return Promise.reject("Fetch did not succeed");
}})
.then(json=>{
console.log("Jetzte kommt POST Body");
console.log(JSON.stringify(json));
})
.catch(err=>console.log(err));
})
//Zapier Hook
Thanks in advance for any help!
Jari