【问题标题】:How to extract the data from a firebase.auth().onAuthStateChanged如何从 firebase.auth().onAuthStateChanged 中提取数据
【发布时间】:2018-03-04 17:35:45
【问题描述】:

我需要获取正在登录的用户的数据。我使用 firebase.auth().onAuthStateChanged 来查看用户是否已登录,然后我 console.log 返回的 userData。

它返回所有用户的数据,见下文,但我找不到如何检索它。我可以检索我知道来自授权但其他数据存在的 userData.email、userData.fullname 和 userData.uid。我知道我可以使用 uid 再次读取数据,但它已经存在了。

如果有人可以帮助我,我将不胜感激。

确认:“新” 电子邮件:“yakr@uacro.com” 全名:“约翰 Varified” 支付类型:“d” 注册日期:“2017 年 9 月 23 日星期六” 主题:“灰色” uid:"FWOb7eJ38veRXQ7wadk77YzhyMj1"

【问题讨论】:

  • 抱歉,直到今天早上我才看到您的回复。我已将用户保存到 firebase 数据库并使用 firebase.auth().onAuthStateChanged 检索它。在控制台日志中,我可以看到所有数据(请参阅原始问题的底部)。 userData.email 等检索“email”、“fullname”和“uid”,但不检索“confirm”、“paytype”、“registrationDate”或“theme”。 Console.log 可以检索它们为什么我不能?

标签: angular firebase-authentication


【解决方案1】:

感谢 Udemy.com 上的基本课程,我找到了丢失的链接。我需要一个服务来设置和销毁本地图像。

export class User2memoryService {

  constructor() {}

  set(userFromDb) {
    localStorage.setItem('user', JSON.stringify(userFromDb));
  }

  destroy() {
    localStorage.removeItem('user');
  }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-08-17
    • 2020-08-06
    • 2016-10-02
    • 2021-06-03
    • 1970-01-01
    • 2018-01-02
    • 1970-01-01
    • 2018-05-12
    相关资源
    最近更新 更多