【问题标题】:Firebase TypeError: Cannot read property 'ac' of undefinedFirebase TypeError:无法读取未定义的属性“ac”
【发布时间】:2018-01-22 03:13:32
【问题描述】:

我使用这个简单的代码在我的网络应用上进行身份验证

firebase.auth().signInWithCustomToken(token).catch(function(error) {
  // Handle Errors here.
    var errorCode = error.code;
    var errorMessage = error.message;
  // ...
});

身份验证后,我在浏览器中收到以下错误:'Firebase TypeError: Cannot read property 'ac' of undefined' 这似乎指向此处的错误:

        h.set = function(a, b, c) {
            var d = this.aa(a, c)
              , e = this
              , f = Si(this, a.B);
            return f.set(d, b).then(function() {
                return f.get(d)
            }).then(function(b) {
                "local" != a.B || this.ac || (e.W[d] = b);
            })
        }
        ;

我正在使用 rollup 和 buble 编译我的 es6 代码。另请注意,在服务器响应中,我似乎已成功进行身份验证。

因为我得到了以下回复:

{
 "kind": "identitytoolkit#VerifyCustomTokenResponse",
 "idToken": "token",
 "refreshToken": "refreshtoken",
 "expiresIn": "3600"
}

请帮忙。谢谢。

【问题讨论】:

    标签: javascript firebase firebase-authentication rollupjs bublejs


    【解决方案1】:

    我相信这与:https://github.com/firebase/firebase-js-sdk/issues/121 How to stop babel from transpiling 'this' to 'undefined'

    引用:“给您带来麻烦的是,在 ES6 模块中,这是未定义的,而在“脚本”情况下,这取决于环境,例如浏览器脚本中的窗口或 CommonJS 代码中的导出。”

    【讨论】:

    • 我认为这可能会有所帮助,但问题是我使用的是 rollup 和 buble,并且该链接仅响应如何在 babel 中进行操作
    【解决方案2】:

    @bojeil 我实际上尝试了您的建议,甚至将我的整个转译器从 buble 更改为 babel,只是为了让它运行。结果一样。

    最后,从 v4.2.0 到 v4.3.0 的更新在发布前 13 小时发布并修复了问题。

    所以对于有同样问题的人来说,更新 firebase。

    【讨论】:

      猜你喜欢
      • 2018-09-19
      • 2019-09-28
      • 2019-04-05
      • 2021-12-05
      • 1970-01-01
      • 2021-07-25
      • 1970-01-01
      • 1970-01-01
      • 2020-11-29
      相关资源
      最近更新 更多