I am trying to get list of pets that owned by current.user.uid but I am facing issues with the backend code. The error stated
Uncaught (in promise) TypeError: Cannot read properties of null (reading 'uid')
This my script
enter code here<script>
// @ is an alias to /src
import getUser from "@/composables/getUser"
import { auth, db } from "@/firebase/config";
import {signOut} from "firebase/auth";
import { collection, onSnapshot, query, where } from '@firebase/firestore';
export default {
name: 'HomeView',
setup(){
const {user} = getUser()
const router = useRouter()
const q = query(collection(db,"pets"),where("UserID", "==", user.value.uid));
const unsubscribe = onSnapshot(q,(querySnapshot)=>{
const pet = [];
querySnapshot.forEach((doc)=> {
pet.push(...doc.data())
});
console.log("Current pets :", pet.join(","))
})
return {q, unsubscribe ,error}
}
}
So, actually i want the document that have the current uid display in the list thanks for helping me