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

查看:51
本文介绍了从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初始化还是其他设置?

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解析的承诺(文档),请参见

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天全站免登陆