firebase.auth()。createUserWithEmailAndPassword Undefined不是一个函数 [英] firebase.auth().createUserWithEmailAndPassword Undefined is not a function

查看:141
本文介绍了firebase.auth()。createUserWithEmailAndPassword Undefined不是一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注用户管理的firebase文档

I am following the firebase documentation on user management

var firebase = require('firebase');

// Initialize Firebase
firebase.initializeApp({
    serviceAccount: "./<mysecreturledittedout>.json",
    databaseURL: "https://<mydatabaseurljusttobesafe>.firebaseio.com"
});

router.get('/create', function(req, res){
    var email = req.email;
    var password = req.password;
    firebase.auth().createUserWithEmailAndPassword(email, password).catch(function(err){ // LINE 27 CRASH
        var errorCode = err.code;
        var errorMessage = error.message;
        console.log("ERROR");
        console.log(errorCode, errorMessage);
    });
});

我收到以下错误

undefined is not a function

TypeError: undefined is not a function
    at d:\Users\Kitty\Code\Practice2\routes\index.js:27:21

从做一点研究,我觉得未定义是不是一个功能基本上是一个空值指针异常的JavaScript版本(可能是错误的)

From doing a little bit of research, I think undefined is not a function is basically a javascript version of a null pointer exception (could be wrong)

我已经配置了我的服务帐户和项目在firebase。我在本地主机上运行。谢谢。我正在寻找调试提示,因为我不知道如何测试什么是不工作。

I have configured my service account and project on firebase. I am running this on localhost. Thanks. I am looking primarily for debugging tips, as I'm not sure how to test what isn't working.

推荐答案

如果你还没有解决问题,我发现为什么它给出这样的错误,这是因为它真的不是一个功能。

If you haven't fixed the problem yet, I found out why it's giving such an error and that's because it really isn't a function.

当您需要使用服务器参考时,您将使用Web引用作为指导: https://firebase.google.com/docs/reference/node/firebase.auth.Auth

You're using the Web reference as your guide when you need to be using the Server reference: https://firebase.google.com/docs/reference/node/firebase.auth.Auth.

如您所见,firebase.auth.Auth与Web API相比,在Node.js API上有很多不同之处,因为没有很多。现在你必须处理令牌,我没有深入研究,如果使用Server API。另一方面,您只需使用Web API即可,您可以执行此操作。

As you can see, firebase.auth.Auth is a lot different on the Node.js API when compared to the Web API as there's not a lot in there. Now you have to deal with tokens, which I haven't looked deep into, if using the Server API. On the other hand, you can just use the Web API, which does things you intended to do.

这篇关于firebase.auth()。createUserWithEmailAndPassword Undefined不是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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