我很擅长使用meteor JS,在尝试将mongo记录提供给电子邮件模板时,我遇到了这个模糊的错误。这是收到的exct错误
`错误阻止启动:
使用ecmascript处理文件时(对于目标os.osx.x86_64): server / 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: 'nayyir.-----@----.com',
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: '------@------.com',
from: '------@------.com',
subject: 'Test',
html: SSR.render('htmlEmail', emailOptions),
});
console.log('on server - sent email');
}
})
});

非常感谢任何帮助!
TIA
答案 0 :(得分:2)
错误表明第22行出现问题,如下所示:
struct in6_addr
我想你忘记了花括号,所以看起来应该是这样的:
var spec = Mongo.collections('specattributes').find('_id': vehicle['specifications'][i]['attr_id']);