So I have a Meteor Method being called on my client with this code:
getTimeSlots.call({id}, (error, result) => {
// returns the result here.
})
And the implementation is:
export const getTimeSlots = new ValidatedMethod({
name: 'timeslots',
validate: new SimpleSchema({
dispensaryId: { type: SimpleSchema.RegEx.Id },
menuType: { type: Boolean }
}).validator(), run({ id }) {
try {
let row = TimeSlots.findOne({
'id': id
})
// This part returns empty on Client browser console
// however returns something on the Server console.
console.log('Row', row)
return row
} catch (e) {
console.log(e.message);
}
}
})
In the method implementation I added a console.log to log the retrieved row however, on my client browser log it’s empty and on the server it’s populated. What is the problem with this code? The method not enclosed inside Meteor.isServer
or a server directory hence, it’s running on both client and server.