2017-09-25 13 views
-2

私はmeteor JSを使用することでかなり新しいです。電子メールテンプレートにmongoレコードを提供しようとすると、このあいまいなエラーに遭遇しました。 サーバ/ main.js:(ターゲットos.osx.x86_64用)のECMAScriptのファイルの処理中にMeteor JSエラー。予期せぬトークン '、' expected '['

:これはEXCTエラーが

`エラー防止起動を受けた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

+1

22行目の行についてのヒントを教えてください。人々があなたを手伝ってくれるようにしたいと思っています。確かに人々は数えられるかもしれませんが、これは*正確に*あなたのコード(多分あなたの空白行が多いか少ないか)、そしてどのような場合に、なぜ人を数えるのか分かりません。 –

+2

[db.collections.find()](https://docs.mongodb.com/manual/reference/method/db.collection.find/#db.collection.find)の構文を確認してください – Ben

答えて

2

エラーは、このような行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']}); 
関連する問題