How to render a template only after a is done?


I’ve got something like this:

Router.route('/:uid', {
  name: 'lookup',
  data: function () {'fetch', this.params.uid, function (error, result) {
      if (typeof error === 'undefined') {
        return result;
      } else {
        return {};

The problem is, the lookup template is done rendering before the data is ready (the call to the fetch method makes a couple API calls), since is asynchronous. What I’d like is to use something like waitOn, but that doesn’t solve the async problem.

I’m out of ideas.


I wound up moving the within the template’s onRendered callback, and using Session.set to put the method’s result in a session var. Then in the route:

data: function () {
  return Session.get('info');


In the future, you can us Promises to get around the async issue.

Check out

Not sure if this would solve the problem inside of the router’s data function (and your end solution is a better approach anyway) but it’s worth looking in to.