Recently, I dove into a project that involves using Next JS and Firebase. After successfully storing data in Cloud Firestore, I encountered an issue when trying to retrieve the length of an array from the database. Below is an image illustrating the data structure stored in Firestore: https://i.sstatic.net/oIw26.png
I attempted the following code snippet:
let len = 0
const ref = firebase.firestore().collection("users").doc(user.uid).get().then(snap => {
len = snap.data().disliked1.length
console.log(len)
})
Unfortunately, running this code returns undefined
.
Any suggestions on how to accurately retrieve the length of the disliked1
array?