-2
我在使用流星JS时很新颖,而且在尝试向电子邮件模板提供mongo记录时遇到了这个难以理解的错误。这是接收到的exct误差流星JS错误;意想不到的令牌','预期'['
`防止错误启动:
在处理与ECMAScript的文件(目标os.osx.x86_64): 服务器/ main.js:22:75:意外令牌,预期] (22:75)
您的应用程序有错误。等待文件更改。“
提供了一段代码片段,用于显示我的服务器文件的外观。
import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo'
Meteor.startup(() => {
// code to run on server at startup
var smtp = {
username: '[email protected]',
password: '-----------------',
server: '----.-----.com',
port: ---
}
var vehicle = Mongo.collections('vehicles').findOne();
var specifications = [];
var user = Mongo.collections('users').findOne();
process.env.MAIL_URL = 'smtps://' + encodeURIComponent(smtp.username) + ':' + encodeURIComponent(smtp.password) + '@' + encodeURIComponent(smtp.server) + ':' + smtp.port;
Meteor.methods({
sendEmail: function() {
console.log('on server - sending email');
SSR.compileTemplate('htmlEmail', Assets.getText('mitsubishi-email.html'));
for (var i in vehicle['specifications']){
var spec = Mongo.collections('specattributes').find('_id': vehicle['specifications'][i]['attr_id']);
var specattributes = {};
specattributes['spec_value'] = vehicle['specifications'][i].val.en;
specattributes['spec_category'] = spec;
specifications.push(specattributes);
}
var emailOptions = {
firstname: user.firstname,
lastname: user.lastname,
specifications = specifications,
improvements = vehicle.improvements,
reasons = vehicle.reasonsToBuy
}
Email.send({
to: '[email protected]',
from: '[email protected]',
subject: 'Test',
html: SSR.render('htmlEmail', emailOptions),
});
console.log('on server - sent email');
}
})
});
任何帮助是非常感谢!
TIA
也许给我们提示哪一行是第22行?你想让人们很容易帮助你。当然,人们可以数数,但我们不知道这恰好是*你的代码(也许你有更多或更少的空白行),并且无论如何,为什么让人数? –
查看[db.collections.find()](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)语法 – Ben