I’ve customized the Event page and extract the ticket and event information from the wix-events collection, i.e Events and Tickets. I’ve noticed that on the live site 2% of the queries to these collection causes network error or other errors and due to that event or ticket data are not returned. I’ve tried many things to resolve this but none resolve it completely.
Copying the ticket definition data to my collections will be problematic in case of tickets as I will need to manage the purchased tickets as well when there’s a limit on a specific ticket.
Is there a solution for this?
Can you share the code for the queries you’re making and the exact error messages you’re getting?
err.message returns “network error” on the page catch()
and recently I also get “WDE0149: Internal application error.” from the backend catch()
The page code:
try {
let tickets = await getTicketDef(eventId, freeTicket, filterTicket)
//… additional logic
} catch (err) {
// logging error to a collection
log(“event page”, "loadTickets, retry count "+loadticketRetryCount.toString(), err.message, event)
return false
}
the backend code (code can be optimized
):
export function getTicketDef(eventId, freeTicketId, filterTicketId) {
return new Promise((resolve, reject) => {
wixData.query("Events/Tickets")
.eq("eventId", eventId)
.find()
.then((results) => {
let items = results.items;
items.sort(function (a, b) {
if (a.name.includes("Counter")) { return 1 }
if (b.name.includes("Counter")) { return -1 }
return a.finalPrice - b.finalPrice;
});
// return only free ticket
if (freeTicketId) {
debugLog("free ticket")
let freeTickets = items.filter(function (ticket) {
return ((ticket.name.includes("free")) && (ticket._id == freeTicketId));
});
debugLog("free ticket after filter", freeTickets)
if (freeTickets.length > 0) {
resolve(freeTickets)
}
}
// return only specific ticket.
if (filterTicketId) {
debugLog("filter ticket")
let filterTickets = items.filter(function (ticket) {
return ((ticket._id == filterTicketId));
});
debugLog("free ticket after filter", filterTickets)
if (filterTickets.length > 0) {
resolve(filterTickets)
}
}
var pricedTickets = items.filter(function (ticket) {
return ticket.fixedPrice != 0;
});
resolve(pricedTickets);
})
.catch((error) => {
log(" getTicketDef()", "getTicketsDef - event id " + eventId , error.message, error)
reject(error)
});
})
}