如何在Vue3中从Firebase Auth获取注册日期?

huangapple go评论67阅读模式
英文:

How can i get the registered-date from Firebase Auth in Vue3?

问题

我需要访问createdAt变量,然后通过date()将其转换为实际日期。但是不知何故,我无法通过auth.currentUser.createdAt变量来访问它。
我该如何做?

简短示例

const date = ref('')
date.value = new Date(auth.currentUser.metadata.createdAt)
// 1676566043721被解释为无效日期

它不起作用,因为new Date与接收到的值同时被渲染。

英文:

I need to access the createdAt variable to convert it via date() to a real date. But somehow, i can't access it by auth.currentUser.createdAt variable.
How can i do that?

Short example

const date = ref('')
date.value = new Date(auth.currentUser.metadata.createdAt)
				//  1676566043721 is interpreted as invalid date

It does not work because new Date is at the same time rendered, as the value received.

答案1

得分: 0

User对象没有createdAt属性。你可能在寻找auth.currentUser.metadata.creationTime

英文:

The User object doesn't have a createdAt property. you're probably looking for auth.currentUser.metadata.creationTime.

huangapple
  • 本文由 发表于 2023年7月24日 00:09:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/76749199.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定