I could really use some assistance. Despite my best efforts over the past few days, and despite watching numerous tutorials and consulting various methods in Firebase documentation, I am still unable to make any progress.
My current project involves building a Vue chat application and attempting to write data into Firebase databases. The contents of my firebase/init.js
file are as shown below:
import { initializeApp } from "firebase/app";
import { getFirestore} from 'firebase/firestore';
const firebaseConfig = {
apiKey: "XXXXXXXXXXXXXXXXXXXXXXXXXX",
authDomain: "XXXXXXXXXXXXXXXXXXXXXXXXXX",
projectId: "XXXXXXXXXXXXXXXXXXXXXXXXXX",
storageBucket: "XXXXXXXXXXXXXXXXXXXXXXXXXX",
messagingSenderId: "XXXXXXXXXXXXXXXXXXXXXXXXXX",
appId: "XXXXXXXXXXXXXXXXXXXXXXXXXX",
measurementId: "XXXXXXXXXXXXXXXXXXXXXXXXXX"
};
const app = initializeApp(firebaseConfig);
const db = getFirestore(app);
export default db;
The scripting section of my CreateMessage.vue file is outlined below:
<script>
import {collection, addDoc} from "firebase/firestore";
export default {
name: 'CreateMessage',
props: ['name'],
data() {
return {
newMessage: null,
errorText: null
}
},
methods: {
createMessage () {
if (this.newMessage != "") {
addDoc(collection(firestore, "messages"),{
message: this.newMessage,
name: this.name,
timestamp: Date.now()
});
this.newMessage = null;
this.errorText = null;
} else {
this.errorText = "A message must be entered first!";
}
}
}
}
</script>
Any guidance or advice on this matter would be immensely appreciated. Thank you all for your help in advance.