Reputation: 85
I have already asked this question before and the solution was to restart my server. I'm using the same code again but this time server restart doesn't help.
import firebase from "firebase";
const firebaseConfig = {
apiKey: "...",
authDomain: "...",
projectId: "...",
storageBucket: "...",
messagingSenderId: "...",
appId: "..."
};
if(!firebase.app.length){
firebase.initializeApp(firebaseConfig);
}
const db = firebase.firestore();
const auth = firebase.auth();
const provider = new firebase.auth.GoogleAuthProvider();
export {db, auth, provider};
Entire error from console: https://i.sstatic.net/XRqD3.png .
If I initialize it out of if statement it gives me and error that default app already exists; tried placing both in if else:
if(!firebase.app.length){
firebase.initializeApp(firebaseConfig);
}else{
firebase.app();
}
but then it goes back to "No Firebase App Default has been created".
Upvotes: 0
Views: 126
Reputation: 599051
I think you're looking for firebase.apps.length
(plural), not firebase.app.length
(singular). Also see https://firebase.google.com/docs/reference/js/firebase#apps
Upvotes: 1