我正在嘗試訪問我在 firebase 中的實時資料庫,但它顯示了這個錯誤Uncaught Error: Service database is not available。我已經搜索了這可能意味著什么,但我找不到任何有用的東西或解決方案。
這是我的代碼:
window.addPerson = addPerson;
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const userVar = urlParams.get('user')
const userVarSplitted = userVar.split('#')
const userVarFormatted = userVarSplitted[0] ":" userVarSplitted[1]
// Import the functions you need from the SDKs you need
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.4/firebase-app.js";
import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.6.4/firebase-analytics.js";
import { getDatabase, ref, set } from "https://www.gstatic.com/firebasejs/9.1.0/firebase-database.js";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {MY FIREBASE CONFIG};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
if (app.length === 0) {
console.log("no firebas app")
}else{
console.log("initialized")
}
const analytics = getAnalytics(app);
const database = getDatabase(app);
function addPerson() {
set(ref(database, "verified/" userVarFormatted), {
name: userVarSplitted[0],
discriminator: userVarSplitted[1]
});
console.log("added")
PS:腳本型別設定為模塊化。
您知道錯誤的含義以及發生了什么嗎?
uj5u.com熱心網友回復:
您正在使用不同版本的 Firebase SDK。我也會將資料庫匯入更新到版本 9.6.4,以便所有 Firebase SDK 版本都相同。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/420628.html
標籤:
