Currently, I am utilizing the ref()
function to store data retrieved from Firebase. However, when attempting to filter and retrieve a single record, the outcome is not as expected. Instead of returning a single object, something different is being displayed. Below is the snippet of my code. Can someone please provide guidance on where I may have made an error?
https://i.stack.imgur.com/ZJ1Oz.png
const topicalData = ref<Array<any>>()
const topicalDataLength = ref(0)
const questions = ref()
topical.onSnapshot((snapshot) => {
topicalData.value = snapshot.docs.map((doc) => {
const data = doc.data()
const id = doc.id
return { id, ...data }
})
topicalDataLength.value = topicalData.value.length
})
const loadQuestions = (id: string) => {
questions.value = topicalData.value?.map((data) => {
return data.id == id ? data : false
})
console.log(questions.value)
// questionTopical.value = true
}