I need to setup firebase and firestore in my vue app.
I've created a folder named firebase
inside the src of my project and inside it I've a file named init.js
I've this code inside the file, but I'm unable to start the firebase ui from my login component
import { initializeApp } from 'firebase/app'
import { getFirestore } from 'firebase/firestore'
import * as firebaseui from 'firebaseui'
const config = {
apiKey: "....",
authDomain: "...firebaseapp.com",
databaseURL: "...firebaseio.com",
projectId: "...",
storageBucket: "..",
messagingSenderId: "...",
appId: "...",
measurementId: "..."
}
const app = initializeApp(config)
const db = getFirestore()
const ui = new firebaseui.auth.AuthUI(app)
export { db, ui }
When I'm importing the ui
const in my component I will get this error:
Uncaught TypeError: Cannot read properties of undefined (reading 'options')
How I can fix this?
CodePudding user response:
As explained in the doc, you need to pass the Firebase App object (i.e. app
) to the getFirestore()
method.
const app = initializeApp(config)
const db = getFirestore(app)