编辑:问题已解决。我最近更改了发布规则,导调用子邮件无法发布到客户端。
我有一个问题:我正在尝试在提交表单时发送通知电子邮件。这是代码
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@email.com",
"You have a new task offer!",
html);
变量所有者是用户 ID。 console.log(owner) 返回正确的 id,console.log(fl) 返回用户对象。但是,调用 fl.emails[0].address
会出现“TypeError: undefined is not an object (evaluating 'fl.emails[0]')”错误。
我有什么遗漏的吗?
最佳答案
Meteor.users.find
返回 cursor并且您需要将用户检索为 js 对象。
尝试:
var fl = Meteor.users.findOne({_id:owner});
// OR
var fl = Meteor.users.findOne(owner)
console.log(fl);
关于javascript - Meteor用户访问数据时未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27155524/