I have the following Meteor method set up:
// Defined in collections/collections.js
Meteor.methods({
email: function(options) {
this.unblock();
Email.send(options);
}
});
which I call like this:
// Defined in client/main.js
Meteor.call('email', {
to: '[email protected]', from: '[email protected]',
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....)
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.
Methods are Meteor's remote procedure call (RPC) system, used to save user input events and data that come from the client.
Meteor. call() is typically used to call server-side methods from the client-side. However, you can also use Meteor. call() on the server-side to call another server-side function, though this is not recommended.
Did you add the email package?
meteor add email
As paul suggested, it looks like the error is that you are trying to call Email.send()
from the client.
Email.send()
can only be called on the server. To solve the issue try moving the method definition to the server.
Email.send()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With