我正在嘗試使用 Firebase 進行電子郵件密碼身份驗證。我在 Firebase 上啟動了一個 web 應用程式,遵循 web 的 Get Started 部分。但是我從以下位置收到此錯誤catch():
[TypeError: undefined is not an object (evalating 'auth.tenantId')]
我的 Firebase 配置:
import { initializeApp } from "firebase/app";
import { getAuth } from "firebase/auth";
import { getFirestore } from "firebase/firestore"
const firebaseConfig = {
apiKey: "",
authDomain: "spotifymockrn.firebaseapp.com",
projectId: "spotifymockrn",
storageBucket: "spotifymockrn.appspot.com",
messagingSenderId: "",
appId: "",
measurementId: "",
};
const app = initializeApp(firebaseConfig);
export const auth = getAuth(app);
export const db = getFirestore(app);
我的注冊螢屏,我handleFirebase在按下注冊時呼叫函式。通常使用也與 AsyncStorage 一起保存,但為簡單起見,我現在嘗試這樣:
import { createUserWithEmailAndPassword } from 'firebase/auth';
import auth from '../../../../firebase/firebase'
.
.
const handleFirebase = () => {
createUserWithEmailAndPassword(auth, email, password).then(response => { console.log(response.user); })
.catch((error) => (console.error(error)));
}
我從 redux 商店收到電子郵件和密碼,但我也嘗試直接在那里寫字串,得到了同樣的錯誤,在網上找不到任何東西。我嘗試撰寫真實的電子郵件以及隨機字串,沒有任何變化。感謝您的閱讀。
uj5u.com熱心網友回復:
import auth from '../../../../firebase/firebase'
此匯入將是一個物件{ auth, db },但您需要將 Firebase Auth 實體傳遞到createUserWithEmailAndPassword(). 嘗試更改您的匯入,如下所示:
// the { }
import { auth, db } from '../../../../firebase/firebase'
現在auth將是 Auth 實體。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/508301.html
標籤:Google Cloud Collective javascript 火力基地 反应式 firebase 身份验证
