Hello,
I start with Wix but I discover that it’s really very complete!
I’m trying to do a little integration, I just want to post on an third party application the information of a wix event when it’s created.
Following what I understood from the documentation, I created an events.js file in backend folder with test http post.
But nothing happens when I create an event in dashboard. I tried my code on an OnClick button and it works.
So I guess I haven’t quite figured out how to trigger this code when an event is created.
events.js (backend)
export function wixEvents_onEventCreated(event) {
let eventId = event.eventId;
let title = event.title;
fetch( “https://url…” , {
“method” : “post” ,
“headers” : {
“Content-Type” : “application/x-www-form-urlencoded”
},
“body” : “somekey=somevalue”
} )
.then( (httpResponse) => {
if (httpResponse.ok) {
return httpResponse.json();
} else {
return Promise.reject( “Fetch did not succeed” );
}
} )
.then( (json) => console.log(json.someKey) )
. catch (err => console.log(err));
}
Best regards,
David.