TypeError: Cannot read property '0' of undefined. when tries to list all users

I have a metoer/vue app but cant list all users on heroku and on the android app, i can list users on localhost.

I get the error with this:

<v-flex style="padding:4px;" v-bind="{ [`xs6`]: true }" v-for="user in theusers" :key="user._id" xs12 sm6 md3 order-md1 order-sm3>

<script>
export default {
meteor: {

theusers () {
  return Meteor.users.find();
 },
},
       
}
</script>

in console:

TypeError: Cannot read property '0' of undefined

I think you need to make it a publication (I’m assuming you haven’t).

So on the server:

Meteor.publish("users", function() {
  return Meteor.users.find();
});

and then subscribe to that publication on the client. By default, all users aren’t exposed on the client. As such I’d also recommend only publishing certain fields (such as _id, username and email but not password etc).

Hope this helps.

perfect it worked…

1 Like