I'm trying to write some data to my Firestore database. I've been following Firebase docs but for some reason nothing is being written to my database. I'm not receiving any console errors but there are no new docs being written. I've also tried using setDoc, but no luck with that either.
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.8/firebase-app.js";
import { getFirestore, doc, setDoc, addDoc, collection } from "https://www.gstatic.com/firebasejs/9.6.8/firebase-firestore.js";
const firebaseConfig = {
...
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const db = getFirestore();
var submitPost = document.getElementById("submitPost");
submitPost.addEventListener("click", writeToDB, false);
async function writeToDB() {
console.log("HIT ME")
const newDoc = await addDoc(collection(db, 'posts'), {
test: 'TEST',
please: 'WORK',
});
};
Here is my Firestore console after running the function, it does not contain any new documents, only one I have already made manually:
