Reputation: 149
EDIT: The problem has been solved. I recently changed the publish rules which caused the emails not to get published to the client.
I have a problem: I am trying to send a notification email upon a form submit. This is the code
var fl = Meteor.users.find({_id:owner});
console.log(fl);
var email = fl.emails[0].address;
var html = Blaze.toHTMLWithData(Template.new_assigned_task_email);
Meteor.call('sendEmail',
email,
"[email protected]",
"You have a new task offer!",
html);
the variable owner is a user ID. console.log(owner) returns the correct id, console.log(fl) returns the user object. However, calling fl.emails[0].address
gives me the "TypeError: undefined is not an object (evaluating 'fl.emails[0]')" error.
is there anything that I am missing?
Upvotes: 0
Views: 187
Reputation: 5273
Meteor.users.find
returns cursor and you need to retrieve user as js object.
Try:
var fl = Meteor.users.findOne({_id:owner});
// OR
var fl = Meteor.users.findOne(owner)
console.log(fl);
Upvotes: 1