Reputation: 171
I'm trying to make a user send their num to another user. I created a random keycode for every user to send each other a num.
I tried accessing the data by querying them.
const sendNum = async(e) => {
const userCol = collection(db, "users")
e.preventDefault();
const targetQuery = query(userCol, where("keycode", "==", target))
const targetSnapshot = await getDocs(targetQuery)
targetSnapshot.forEach((doc) => {
console.log(doc.data().num);
})
console.log(targetSnapshot);
But it returns an object rather than the another user's num field
Nu {_firestore: xc, _userDataWriter: ah, _snapshot: Oo, metadata: Su, query: Ic}
Here's what the data looks like:
Upvotes: 3
Views: 74
Reputation: 1420
Posting the solution suggested by Doug Stevenson as a Community Wiki for visibility.
From the description it's not possible to tell what value the target
holds.
In this case, hard coding the value worked to access the user field.
Upvotes: 1