:( Unexpected article='undefined' appears and breaks down my app


#22

Yes, I suppose that since you have no subscriptions when the template is being rendered, your Template.subscriptionsReady will return true and it attempts to render without actually having data. A way through that, to test, would be to set a RecativeVar to true after it has subscribed and use a helper to check that var instead on Template.subscriptionsReady.

But try just put it all in onRendered first


#23

Oh, and if you put it in a autorun, when the Flowrouter is ready it will run the correct subscription (it will re-run when the param changes). After you page is loaded, just run FlowRouter.getParam(“id”) in the console and you will see it is the new id


#24

console.log returns id of previos article, not of newly created.
Template still doesn’t renders , but at least now I know what happens

Yes, it subscribes on the old id, but when the helper is called, it has the new id, not the one you subscribe on


#25

tnanks a lot, it works with this code:

Template.ArticlePage.onCreated(function() {
  var self = this;
  self.autorun(function() {
    const id = FlowRouter.getParam("id");
    if (id) {
      self.subscribe("articleSingle", id);
    }
  });
});