Is anyone else getting the following error from Iron-Router since upgrading Meteor to version 1.0?
Please post here if you know how to resolve this issue.
There was a non backwards-compatible change in the newest version of Iron Router. The migration guide says:
onRun
andonBeforeAction
hooks now require you to callthis.next()
, and no longer take apause()
argument. So the default behaviour is reversed. For example, if you had:
Router.onBeforeAction(function(pause) {
if (! Meteor.userId()) {
this.render('login');
pause();
}
});
You'll need to update it to
Router.onBeforeAction(function() {
if (! Meteor.userId()) {
this.render('login');
} else {
this.next();
}
});
More information
In your case, the by-the-book fix would be to add this.next()
at the end of onBeforeAction
. However, you should rather use waitOn
:
waitOn: function () {
return Meteor.subscribe("userData");
}
That way, you can set a loadingTemplate
which will appear while the userData
subscription is loading.