使用autoform处理meteor中的评论表单。
METEOR@1.4.2.3
aldeed:autoform
从autoform docs,这是我的服务器端功能,使用以下格式发送电子邮件:
Meteor.methods({
sendRequestEmail: function(doc) {
console.log("Sending request email...");
// Important server-side check for security and data integrity
check(doc, Schemas.RequestForm);
// Build the e-mail text
var text = "Name: " + doc.name + "\n\n" +
"Email: " + doc.email + "\n\n\n\n" +
doc.message;
this.unblock();
// Send the e-mail
Email.send({
to: "user@site.com",
from: doc.email,
subject: doc.name + " request",
text: text
});
}
});
但这是我在服务器控制台中遇到的错误:
Exception while invoking method 'sendRequestEmail' ReferenceError: check is not defined
at [object Object].sendRequestEmail (server/main.js:13:5)
at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1711:12)
at packages/ddp-server/livedata_server.js:711:19
at [object Object]._.extend.withValue (packages\meteor.js:1122:17)
at packages/ddp-server/livedata_server.js:709:40
at [object Object]._.extend.withValue (packages\meteor.js:1122:17)
at packages/ddp-server/livedata_server.js:707:46
at Session.method (packages/ddp-server/livedata_server.js:681:23)
at packages/ddp-server/livedata_server.js:551:43
检查不是autoform的一部分吗?
答案 0 :(得分:0)
事实证明,没有检查不是autoform的一部分。这是一个简单的解决方法:
> meteor add check
呼!