codysehl
codysehl

Reputation: 1595

Iron router params empty

Yesterday I updated meteor and my meteorite packages to their latest versions. Today, iron router is not behaving. When I navigate to a parameterized route, the parameter is not loaded. What gives? I have looked at the documentation for iron-router, and it still specifies the same scheme I was using before.

This is the routes file I have created

Router.map(function() {
  this.route('home', {
    path: '/'
  });

  this.route('list', {
    path: '/:_id',
    waitOn: function() {
      return Meteor.subscribe('lists')
    },
    data: function() {
      var list = Lists.findOne({
        _id: this.params._id
      });
      Session.set('listId', list._id);
      return list;
    }
  });
});

When I load a page to http://localhost/1234 the path in iron router is correctly set to /1234 but it does not recognize the last bit as a parameter.

Upvotes: 2

Views: 568

Answers (1)

Tomasz Lenarcik
Tomasz Lenarcik

Reputation: 4880

I am afraid that what is empty is not your this.params object but rather the list document, at least for the first time the route is being executed. This is caused, of course, by the latency related to fetching server data.

You may be thinking that it shouldn't happen because you have used the waitOn hook. But for this to work you would also need to do two other things:

Router.onBeforeAction('loading');

and define the loading template:

Router.configure({
  loadingTemplate: 'someTemplateName'
});

so please update if you haven't done it already.

Upvotes: 1

Related Questions