Closed daslicht closed 11 years ago
Because the route initially runs while the subscription is still loading from the server. Then, once the data is available, it reactively re-runs with the correct data.
so its not a good idea to query the db in my routes ?
Lets say i have this route: '/blog/:_postId': as long as the client calls it with parameters anything is fine
now like to have another router which reacts to just /blog but calls automatically the most recent post So my idea was to just query the db and redirect to my '/blog/:_postId': route. Whats teh best way to solve this, please?
You need to check whether the subscription is ready (you can use the ready()
method on the subscription handle).
So something like:
if (postsSub.ready()) {
var recentPost = Posts.findOne(...);
} else {
return 'loading';
}
thank you
And postsSub would be Meteor.subscribe('postsSub'); ?
I tried it i get postsSub is undefined
Something like postsSub = Meteor.subscribe('posts');
:+1:
Very nice Its now working !!! Thank you very much !
Hi, i have the following Route:
When I call it I get the following message in my console:
Why is the Route called twice ? and why is the first 'mostRecentPost' undefined?