简体   繁体   中英

Firebase TypeError: Cannot read property 'ac' of undefined

I use this simple code to authenticate on my web app

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

After authentication I get the following error in my browser: 'Firebase TypeError: Cannot read property 'ac' of undefined' which seems to point to an error here:

        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);
            })
        }
        ;

I'm compiling my es6 code using rollup and buble. Also please note that on the server response it looks like I'm successfully authenticating.

Because I got the following response:

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

Please help. Thanks.

I believe this is related to: https://github.com/firebase/firebase-js-sdk/issues/121 How to stop babel from transpiling 'this' to 'undefined'

Quoting: "The thing that is causing you trouble is that in an ES6 module, this is undefined, whereas in the "script" case, this varies depending on the environment, like window in a browser script or exports in CommonJS code."

@bojeil I actually tried your suggestion and even changed my whole transpiler from buble to babel, just to get it going. Same result.

In the end, an update from v4.2.0 to v4.3.0 was release just 13 hours before this was posted and fixed the issue.

So to whomever have the same issue, updating firebase.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM