Meteor.wrapAsync 未使用 Meteor.Mandrill 返回任何值
Meteor.wrapAsync is not returning any value with Meteor.Mandrill
我正在尝试在服务器端方法中使用 Meteor.Mandrill.send 函数。
我希望山魈方法是同步的,所以我尝试了这个:
sendActivationCode: function(liftId, email) {
check(liftId, String);
check(email, String);
var body = 'hello';
wrappedMandrillSend = Meteor.wrapAsync(Meteor.Mandrill.send, Meteor.Mandrill);
var sentMail = wrappedMandrillSend({
host: "smtp.mandrillapp.com",
port: 587,
to: email,
from: "info@website.meteor.com",
subject: 'Activation mail',
html: body,
authentication: "LOGIN",
username: Meteor.settings.mandrill.username,
password: Meteor.settings.mandrill.password
});
console.log('sync mail send');
return sentMail;
}
但是 sync mail send
永远不会显示。并且函数永远不会返回。
感谢您的帮助。
如果您正在使用此软件包:https://atmospherejs.com/wylio/mandrill (wylio:mandrill
) 您不需要使用 wrapAync。只需正常使用即可:
sendActivationCode: function(liftId, email) {
check(liftId, String);
check(email, String);
var body = 'hello';
var sentMail = Meteor.Mandrill.send({
host: "smtp.mandrillapp.com",
port: 587,
to: email,
from: "info@website.meteor.com",
subject: 'Activation mail',
html: body,
authentication: "LOGIN",
username: Meteor.settings.mandrill.username,
password: Meteor.settings.mandrill.password
});
console.log('sync mail send');
return sentMail;
}
它不起作用的原因是它试图使一个已经同步的方法再次同步。它没有回调因此不会 return.
我正在尝试在服务器端方法中使用 Meteor.Mandrill.send 函数。
我希望山魈方法是同步的,所以我尝试了这个:
sendActivationCode: function(liftId, email) {
check(liftId, String);
check(email, String);
var body = 'hello';
wrappedMandrillSend = Meteor.wrapAsync(Meteor.Mandrill.send, Meteor.Mandrill);
var sentMail = wrappedMandrillSend({
host: "smtp.mandrillapp.com",
port: 587,
to: email,
from: "info@website.meteor.com",
subject: 'Activation mail',
html: body,
authentication: "LOGIN",
username: Meteor.settings.mandrill.username,
password: Meteor.settings.mandrill.password
});
console.log('sync mail send');
return sentMail;
}
但是 sync mail send
永远不会显示。并且函数永远不会返回。
感谢您的帮助。
如果您正在使用此软件包:https://atmospherejs.com/wylio/mandrill (wylio:mandrill
) 您不需要使用 wrapAync。只需正常使用即可:
sendActivationCode: function(liftId, email) {
check(liftId, String);
check(email, String);
var body = 'hello';
var sentMail = Meteor.Mandrill.send({
host: "smtp.mandrillapp.com",
port: 587,
to: email,
from: "info@website.meteor.com",
subject: 'Activation mail',
html: body,
authentication: "LOGIN",
username: Meteor.settings.mandrill.username,
password: Meteor.settings.mandrill.password
});
console.log('sync mail send');
return sentMail;
}
它不起作用的原因是它试图使一个已经同步的方法再次同步。它没有回调因此不会 return.