Hi, I’m trying to insert the event data into a separate database whenever the rsvp form is completed. I’m using the backend function wixEvents_onRsvpCreated in the events.js file located under backend tab. As I understand it backend events are not fired during preview so I’m publishing the site and testing it in live.
The code is really very simple:-
import wixData from 'wix-data';
export function onRsvpCreated(rsvp) {
let toSave = {
"rsvpId": rsvp.rsvpId,
"eventId": rsvp.eventId,
"totalGuests": rsvp.guests.length,
}
wixData.save("eventStatistics", toSave)
.then( (results) => {
let item = results;
} )
.catch( (err) => {
let errorMsg = err;
console.error(errorMsg);
} );
}
but as far as I can tell it isn’t firing.
As usual I expect I’m making a simple error or I’ve got completely the wrong end of the stick! Your help would be gratefully received.