Search code examples
mongodbtwittermeteoruser-accounts

Meteor: Fetching Data From Account-Twitter Mongo Collection


I'm trying to display some data from the accounts-twitter package. I need the user's profile pic, username, and name, all from Twitter. I've checked using meteor mongo to see that this data is in there. Profile.html is where I store my templates for this:

<template name="profile">
    <div class="col s4">
    <div class="z-depth-2">
      <div class="card blue-grey darken-1">
        <div class="card-content white-text">
          <img class="circle-profile center-align" src="{{services.twitter.profile_image_url}}" style="border-radius: 50%" width="50px" height="50px"/>
          <br>
          <span class="card-title">{{profile.name}}</span>
        </div>
        <div class="card-action">
          <a href="http://twitter.com/{{services.twitter.screenName}}">View Profile</a>
        </div>
      </div>
    </div>
    </div>
</template>

<template name="display">
  {{#each users}}
    {{> profile}}
  {{/each}}
</template>

I also have profile.js that fetches the data from the collection using a helper:

Template.display.helpers({
  users: function() {
    return Mongo.users.find();
  }
});

When I look at my main area, the profiles I have in the collection aren't showing. Please advise. Thanks in advance!


Solution

  • From the docs

    The profile is published by default and only updatable by the current user. The services, where the Twitter information is stored is not because that would be a security issue since it contains the authentication tokens. What would probably work best is in the onCreateUser() method copy those values to the profile so they are published.

    You could also publish only those fields you need from the services but I personally like to keep that separate since it contains sensitive information.