从 Firebase 登录返回的对象 [英] Object returned from Firebase signIn

查看:15
本文介绍了从 Firebase 登录返回的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个针对 Firebase 的 vue 项目.第一个项目由 webpack-simple 创建,另一个项目由 webpack 创建.在简单项目中调用 signInWithEmailAndPassword 时,它只返回 -

I have two vue projects against Firebase. The first project is created by webpack-simple and the other with just webpack. When calling signInWithEmailAndPassword in the simple project it returns just -

{"uid": "xxxxx", ....}

而另一个项目返回一个带有对象的对象

while the other project returns a object with a object

{"user": {"uid": "xxxxx", ....}}

是因为不同的 webpack init 还是其他一些设置?

Is it because the different webpack init or could it be some other settings?

推荐答案

vue.js webpack 模板的类型(vuejs-templates webpack 或 webpack-simple)不应该对返回 Firebase 方法的内容有任何影响.

The type of vue.js webpack template (vuejs-templates webpack or webpack-simple) should not have any influence on what return Firebase methods.

在 Firebase JavaScript SDK 5.0.0 版(2018 年 5 月 8 日发布)中,signInWithEmailAndPassword() 的返回类型签名发生了变化:它返回一个使用 UserCredential(doc)用于返回 user(doc) 在之前的版本中,请参见 https://firebase.google.com/support/release-notes/js

With version 5.0.0 of the Firebase JavaScript SDK (released on May 8, 2018), the return type signature for signInWithEmailAndPassword() has changed: it returns a promise that resolves with a UserCredential (doc) while it used to return a user (doc) in the previous version, see https://firebase.google.com/support/release-notes/js

看看你从 signInWithEmailAndPassword() 方法得到了什么:

Looking at what you get from the signInWithEmailAndPassword() method:

{"uid": "xxxxx", ....} 对应一个user 对象

{"user": {"uid": "xxxxx", ....}}UserCredential 对象.

您可能在两个项目中使用了两个不同版本的 SDK(一个 < 5.0.0 和一个 >= 5.0.0).您可以在 package.json 文件中检查.

You are probably using two different versions of the SDK in your two projects (one < 5.0.0 and one >= 5.0.0). You can check that in the package.json files.

这篇关于从 Firebase 登录返回的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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