Reputation: 31
I'm trying to access data from a firestore document, but I'm getting an error message that exercise.data() is not a function
. I don't understand how the exercisesToAdd
array is an array of documents, but I can't use .data()
to get the contents of the items? How else would I go about getting the data from those documents?
I know the exercisesToAdd
array is actually being filled with documents because I see them in the database when I send the array. Seems straight-forward but I must be missing something.
chosenExercises.forEach((exercise) => {
exercisesToAdd.push(doc(db, 'Users/' + auth.currentUser.uid + '/Exercises/' + exercise));
});
exercisesToAdd.forEach((exercise) => {
console.log(exercise.data());
});
Upvotes: 1
Views: 589
Reputation: 515
As @Doug Stevenson stated in his comment:
Your code hasn't actually performed any queries, so there is no document data available. Please review the documentation and use
get()
to execute each document query first before callingdata()
on anything. Alldoc()
does is create a DocumentReference, which doesn't contain any data.
Upvotes: 1