I am attempting to call the cloud function called getAllEvents, however when I do, I get an error in the console saying âUncaught (in promise) Error: result.get is not a functionâ. Slightly unsure as to why this is happening.
Moralis.Cloud.define('getAllEvents', async (req) => {
const query = new Moralis.Query('Event');
req.params.onlyUpcoming && query.greaterThan('eventDate', new Date());
const result = await query.find();
const results = {
eventDescription: result.get('eventDescription'),
eventName: result.get('eventName'),
eventOrganiser: result.get('eventOrganiser'),
eventVenue: result.get('eventVenue'),
eventDate: new Intl.DateTimeFormat('en-GB', {
dateStyle: 'short',
timeStyle: 'short',
}).format(result.get('eventDate')),
tickets: await Moralis.Cloud.run('getTicketsForEvent', {
eventId: result.get('objectId'),
limit: undefined,
}), // getTicketsForEvent(result.get('objectId')),
};
return results;
});
Moralis.Cloud.define('getTicketsForEvent', async (req) => {
const query = new Moralis.Query('Ticket');
query.equalTo('eventId', req.params.eventId);
req.params.limit && query.limit(req.params.limit);
const queryResult = await query.find();
const results = queryResult.map((x) => ({
objectId: x.get('id'), // this is returning undefined
eventId: x.get('eventId'),
numberMinted: x.get('numberMinted'),
art: x.get('artURL'),
color1: x.get('color1'),
color2: x.get('color2'),
fontColor: x.get('fontColor'),
ticketName: x.get('ticketName'),
ticketPrice: x.get('ticketPrice'),
ticketQuantity: x.get('ticketQuantity'),
}));
return results;
});