In a Vue/Firebase app, I have a nested onSnapshot attached to a single document. I get the following error:
This is my code:
import { onSnapshot, query, collection, collectionGroup, getDocs, where, doc, updateDoc, getDoc, orderBy, addDoc, limit } from 'firebase/firestore'
import { getAuth, signInWithEmailAndPassword, createUserWithEmailAndPassword, onAuthStateChanged, signOut } from "firebase/auth";
import { db } from "../firebase/index";
import store from "../store/index";
//Get loggedin user data
const auth = getAuth();
onAuthStateChanged(auth, (user) => {
if (user) {
onSnapshot(qUserData, (snapshot) => {
store.state.userData = {}
snapshot.docs.forEach((doc) => {
let user = doc.data()
user.id = doc.id
store.state.userData = user
//This is what throws the error
const teamDocRef = doc(db, "teams", user.teamid)
onSnapshot(teamDocRef, (docSnapshot) => {
console.log("Current data: ", docSnapshot.data());
});
})
})
}
})
Thanks for any help!
