Javascript Meteor路由器数据函数被调用两次

Javascript Meteor路由器数据函数被调用两次,javascript,meteor,iron-router,Javascript,Meteor,Iron Router,我有一个路由器数据函数,它调用Meteor方法将新文档插入到集合中。我注意到文档被插入了两次,然后我注意到每次访问路由时都会调用两次数据函数本身。我不明白为什么会这样 Router.route('/myurl',{ name: 'myurl', path: '/myurl', data: function () { console.log('dupe?'); // the data function is an example where th

我有一个路由器数据函数,它调用Meteor方法将新文档插入到集合中。我注意到文档被插入了两次,然后我注意到每次访问路由时都会调用两次数据函数本身。我不明白为什么会这样

Router.route('/myurl',{
    name: 'myurl',
    path: '/myurl',
    data: function () {
        console.log('dupe?');
      // the data function is an example where this.params is available

      // we can access params using this.params
      // see the below paths that would match this route
      var params = this.params;

      // we can access query string params using this.params.query
      var post = this.params.query;

      // query params are added to the 'query' object on this.params.
      // given a browser path of: '/?task_name=abcd1234
      // this.params.query.task_name => 'abcd1234'
      if(this.ready()){
          Meteor.call('points.add', post, function(error, result){
            if(error)
            {
                Session.set("postResponse", "failed");
            }
            else
            {
                Session.set("postResponse", "success");
            }
          });

          return {_message: Session.get("postResponse")};

        }
    }
});

我可以通过将数据下的所有内容移动到Router.onRun钩子来解决这个问题