I use NextJS
const db = getDatabase()
const getTeamData = (teamName: string) => {
onValue(ref(db, teamName), snapshot => {
return snapshot.val()
})
}
console.log(getTeamData('exampleTeam'))
I do have this exampleTeam
in the database; however, it returns undefined anyway. But why?
I have tried this:
let ret: any[] = []
onValue(ref(db, teamName), snapshot => {
ret.push(snapshot.val())
})
return ret[0]
}
But it still returns undefined.
Also, if I change something in the code so that it does a fast reload, then all of the correct data is printed and it works good.
Via Active questions tagged javascript - Stack Overflow https://ift.tt/dvVfGw8
Comments
Post a Comment