0

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.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Erik Martín Jordán
  • 4,332
  • 3
  • 26
  • 36
  • I've found a related issue on GitHub. See [this thread](https://github.com/denoland/deploy_feedback/issues/131#issuecomment-1007323130). It solves the issue if you import from gstatic.com rather than from skypack.dev – Erik Martín Jordán Mar 15 '22 at 16:33

1 Answers1

0

You're using difference versions of the Firebase SDKs. I'd update the database import to version

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 16 '22 at 11:07