gpt4 book ai didi

javascript - Firebase:在测试期间我得到 "undefined is not a function"

转载 作者:行者123 更新时间:2023-11-28 18:33:43 25 4
gpt4 key购买 nike

这是我使用的代码:

var cred = firebase.auth().EmailAuthProvider($scope.data.mail, $scope.data.pwd);

firebase.auth().signInWithCredential(cred)
.then(function()

在测试过程中,我收到以下错误:

TypeError: undefined is not a function (evaluating 'firebase.auth().EmailAuthProvider($scope.data.mail, $scope.data.pwd)')

那么我的代码有什么问题吗?我该如何解决这个问题?

最佳答案

要通过电子邮件/密码登录用户,您只需调用 signInWithEmailAndPassword 方法。

firebase.auth().signInWithEmailAndPassword(email, password).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// ...
});

然后您可以监听实时身份验证事件:

firebase.auth().onAuthStateChanged(function(user) {
if (user !== null) {
console.log('logged in!');
}
});

Check the docs here for more on email login.

Check the API reference for onAuthStateChanged for more info.

关于javascript - Firebase:在测试期间我得到 "undefined is not a function",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37501561/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com