I'm trying to initialiaze Firebase and get the database reference using Skypack:
import { initializeApp } from 'https://cdn.skypack.dev/@firebase/app'
import { getDatabase, onValue, push, ref, runTransaction } from 'https://cdn.skypack.dev/@firebase/database'
const firebaseConfig = {
apiKey: "AIzaSyBd89DtdK1HdkooqZyGAO-Tjdy9OFUGlKI",
authDomain: "qtal-pre.firebaseapp.com",
projectId: "qtal-pre",
storageBucket: "qtal-pre.appspot.com",
messagingSenderId: "542608573279",
appId: "1:542608573279:web:860d687a1a26fd6a7decea"
}
const app = initializeApp(firebaseConfig)
const db = getDatabase(app)
I get the following error:
Uncaught Error: Service database is not available
When I debug both initializeApp
and getDatabase
, they seem to be imported correctly. I'm not quite sure if the problem is due to Skypack imports, Firebase library itself, or perhaps CodePen. Any ideas?
Example at CodePen.