Im trying to connect my project with Cloud Firestore, but when i put the necesary code, bring me this error:
errors.ts:91 Uncaught FirebaseError: Firebase: Firebase App named '[DEFAULT]' already exists (app/duplicate-app).
at initializeApp (https://www.gstatic.com/firebasejs/8.6.2/firebase-app.js:1:17950)
at Object.H.initializeApp (https://www.gstatic.com/firebasejs/8.6.2/firebase-app.js:1:21516)
at file:///C:/Users/Angel/Desktop/Imagine/index.js:28:10
The code that i put was:
firebase.initializeApp({
apiKey: "myapikey",
authDomain: "mydomain",
projectId: "myprojectid"
});
var db = firebase.firestore();
db.collection("users").add({
first: "Ada",
last: "Lovelace",
born: 1815
})
.then((docRef) => {
console.log("Document written with ID: ", docRef.id);
})
.catch((error) => {
console.error("Error adding document: ", error);
});
Aucun commentaire:
Enregistrer un commentaire