Meteor novice-- display list of user emails

Hi all, I’m new to Meteor (and any kind of back-end in general), and I’m having some trouble displaying a list of registered users. Right now it’s coming back blank, but with the correct number of rows in the table. Here’s the html:

<template name="users">
  <h2>Users</h2>
    <table>
      <tr><th>Email</th></tr>

      {{#each users}}
        {{> user}}
      {{/each}}
    </table>
</template>

<template name="user">
  <tr><td>{{userEmail}}</td></tr>
</template>

The publish:

Meteor.publish('users', function() {
  return Meteor.users.find({}, {fields:{emails:1}});
})

The subscribe:

Meteor.subscribe('users');

The helper:

Template.users.helpers({
  users: function(){ return Meteor.users.find(); },
  userEmail: function() {  return this.emails[0].address; },
});

I’m not having any trouble with other collections, but maybe I’m missing something with the users collection. Since the table has the correct number of rows, it appears that the publish/subscribe is going through correctly.

Thanks in advance for the help.

You defined the userEmail helper in the users template, but you’re accessing it in the user (singular) template.

Template.users.helpers({
  users: function(){ return Meteor.users.find(); },
   // move this line to Template.user.helpers
  // userEmail: function() {  return this.emails[0].address; },
});
1 Like

Thanks! That worked. So simple, I should have seen it.