流星JS错误;意外令牌','预期的'['



我在使用Meteor JS方面很新,并且在尝试将Mongo记录提供给电子邮件模板时,我遇到了这个晦涩的错误。这是收到的EXCT错误

`错误阻止了启动:

在使用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: '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

错误表明第22行上有一个问题,看起来像这样:

var spec = Mongo.collections('specattributes').find('_id': vehicle['specifications'][i]['attr_id']);

我认为您忘记了卷曲牙套,所以看起来应该像这样:

var spec = Mongo.collections('specattributes').find({'_id': vehicle['specifications'][i]['attr_id']});

相关内容

最新更新