在Discover Meteor中,如果使用accounts-twitter,如何访问“作者”用户名?

时间:2015-08-15 09:28:25

标签: meteor meteor-accounts

我正在使用Discover Meteor并使用accounts-twitter而非account-password。

添加帖子时,author是使用user.username设置的,但这不适用于accounts-twitter。

如何访问Twitter句柄以设置作者?

我已经尝试了user.services.twitter.screenName,但这没有做任何事。

1 个答案:

答案 0 :(得分:0)

原来这个问题与出版物有关。

请务必包含以下内容,以便在客户端中访问Twitter个人资料信息。

在服务器上:

Meteor.publish("userData", function () {
return Meteor.users.find({_id: this.userId},
    {fields: {'services.twitter': 1}});
});

并且,在客户端:

Meteor.subscribe('userData');