Reactive Join not working

Hi,

My objective is to pick data from two different collections, combine it in one cursor, iterate over it and present it in html. I’ve seen a couple of posts around here that spoke of this, but I couldn’t really make sense of them.

I tried to use a tutorial from here: https://www.discovermeteor.com/blog/reactive-joins-in-meteor/ (point 4)

Here’s a code excerpt:-

The publications code (on the server):

Meteor.publish('topPosts', function() {
  return Posts.find({}, {sort: {score: -1}, limit: 50});
});

Meteor.publish('authors': function(userIds) {
  return Meteor.users.find({_id: {$in: userIds}});
});

The router code (on the client)

Router.map(function() {
  this.route('topPosts', {
waitOn: function() {
  // tell the router to wait until topPosts's data is available to load the route
  return Meteor.subscribe('topPosts');
},
data: function() {
  // return all posts currently available on the client as the route's data context
  return Posts.find();
},
before: function() {
  // let's make sure that the topPosts subscription is ready and the posts are loaded
  if (this.data()) {
// we can then extract the userIds of the authors
var userIds = this.data().map(function(p) { return p.userId });
// and add the authors subscription to the route's waiting list as well
this.subscribe('authors', userIds).wait();
  }
}
  });
});

I’m not sure how I can use this output in my helper. I tried using this.data() but that didn’t work.