Meteor 电子邮件未定义,但从 Meteor.methods 运行 [英] Meteor Email not defined, but is running from Meteor.methods
问题描述
我设置了以下 Meteor 方法:
I have the following Meteor method set up:
// Defined in collections/collections.js
Meteor.methods({
email: function(options) {
this.unblock();
Email.send(options);
}
});
我这样称呼它:
// Defined in client/main.js
Meteor.call('email', {
to: 'yeahright@noneya.com', from: 'yeahright@noneya.com',
text: 'testing testing'
});
我收到两个错误,一个在浏览器控制台中:
I get two errors, one in the browser console:
Exception while simulating the effect of invoking 'email'
ReferenceError {stack: "ReferenceError: Email is not defined↵ at Meteor…js?acc2397bd1f7321a583a30e0d4628ec4f9fded4b:369:3", message: "Email is not defined"}
ReferenceError: Email is not defined
(etc....)
我的服务器 shell 中的另一个运行 meteor
:
the other in my server shell running meteor
:
Exception while invoking method 'email' ReferenceError: Email is not defined
(etc....)
这是怎么回事?我觉得我完全遵循了文档说明,我没有做任何类似的错误就像这个或这个.
What's going on? I feel like I've followed the documentation's instructions exactly, and I'm not doing anything similarly wrong as in questions like this one or this one.
推荐答案
正如 paul 建议的那样,它看起来像错误是您试图从客户端调用 Email.send()
.
As paul suggested, it looks like the error is that you are trying to call Email.send()
from the client.
Email.send()
只能在服务器上调用.要解决此问题,请尝试将方法定义移至服务器.
Email.send()
can only be called on the server. To solve the issue try moving the method definition to the server.
这篇关于Meteor 电子邮件未定义,但从 Meteor.methods 运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!