I use get() from firebase in a function but it can only log in the console the data from the database. Is it possible to get back the data in the funcntion ? Here is the code :
function readAccount(userId) {
const dbRef = ref(getDatabase());
get(child(dbRef, `users/${userId}/bank:/credit`)).then((snapshot) => {
if (snapshot.exists()) {
console.log(snapshot.val());
return snapshot.val();
} else {
console.log("No data available");
}
}).catch((error) => {
console.error(error);
});
}
Via Active questions tagged javascript - Stack Overflow https://ift.tt/LEJHyeB
Comments
Post a Comment