【问题标题】:Meteor : to get and show github username and emailMeteor:获取并显示 github 用户名和电子邮件
【发布时间】:2013-09-24 15:18:15
【问题描述】:

我从 GitHub API 获得了用户名和电子邮件地址。但它没有显示在 Meteor 中。它适用于 profile.name 但不适用于 services.github.username 或电子邮件

 Template.input_box.events = {
"keydown input#message" : function(event){
    if (event.which == 13) { 
    // 13 is the enter key event

        if (Meteor.user())
        {
            var name = Meteor.user().profile.name;
            // var git_userid = Meteor.user().services.github.username;             
            // var git_email = Meteor.user().services.github.email;
        }

这很奇怪,因为 Meteor.user().services.github.username;在控制台模式下工作,但如果我输入我的代码并在本地主机中运行,它不会显示任何内容......调用这个的代码

    {{git_email}} {{git_userid}}  // does not work
    {{name}}    // works

如何使它们工作,以便我可以在我的 HTML 中插入电子邮件和用户名信息。

谢谢

【问题讨论】:

    标签: javascript html github meteor meteorite


    【解决方案1】:

    来自流星docs

    默认情况下,当前用户的用户名、电子邮件和个人资料是 发布给客户端。

    因此您需要在服务器上手动发布用户的“服务”字段。

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

    【讨论】:

      猜你喜欢
      • 2017-10-20
      • 1970-01-01
      • 2015-06-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-14
      相关资源
      最近更新 更多