访问Meteor JS应用程序中的用户电子邮件地址 [英] Access user email address in Meteor JS app

查看:99
本文介绍了访问Meteor JS应用程序中的用户电子邮件地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Meteor构建应用程序,需要访问已登录用户的存储电子邮件地址。

I am building an app using Meteor and need to access the stored email address of a logged-in user.

我目前正在使用:

var userObj = Meteor.user();
console.log(userObj);

访问用户。但是,我只能访问id。电子邮件地址存储在嵌套对象中,如下所示:

to access the user. However, I am only able to access the id. The email address is stored in a nested object that looks like this:

[Object {address="address@gmail.com", verified=false}]

我尝试了各种方法来遍历JSON对象,但无法计算如何访问我需要的值。

I have tried various ways to traverse the JSON object but can't figure out how to access the value I need.

推荐答案

Meteor.user()。电子邮件[0] .address 适合我。

以下是该文档所说的内容:

Here's what the doc says:


默认情况下,服务器会发布用户名,电子邮件和个人资料。有关用户文档中使用的字段的更多信息,请参阅
Meteor.users

示例用户文档:

{
  _id: "bbca5d6a-2156-41c4-89da-0329e8c99a4f",  // Meteor.userId()
  username: "cool_kid_13", // unique name
  emails: [
    // each email address can only belong to one user.
    { address: "cool@example.com", verified: true },
    { address: "another@different.com", verified: false }
  ],
  createdAt: 1349761684042,
  profile: {
    // The profile is writable by the user by default.
    name: "Joe Schmoe"
  },
  services: {
    facebook: {
      id: "709050", // facebook id
      accessToken: "AAACCgdX7G2...AbV9AZDZD"
    },
    resume: {
      loginTokens: [
        { token: "97e8c205-c7e4-47c9-9bea-8e2ccc0694cd",
          when: 1349761684048 }
      ]
    }
  }
}

这篇关于访问Meteor JS应用程序中的用户电子邮件地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆