I'm currently trying to upgrade my firebase code from version 8 to 9. However, I've encountered this error when I'm trying to get data from the database. It seems that await is causing the problem and I'm still pretty new in async.
function checkDatabaseData() {
const uid = localStorage.getItem("uid");
const docRef = doc(db, "userAdminCreds", uid);
const docSnap = await getDoc(docRef);
if (docSnap.exists()) {
console.log("Document Data:", docSnap.data());
return true;
} else {
console.log("No data");
return false;
}
}
checkDatabaseData();
The HTML script tag
<script type="module" defer src="js/firebase-firestore-dashboard.js"></script>
This is just the same from the firebase guide: https://firebase.google.com/docs/firestore/query-data/get-data?authuser=0#web-version-9_1