i m new in firebase and i m trying to get data from firebase database
JS Code :
const userAnswersRef = admin.database().ref('/ChatbotProj/answers').child(userId);
return userAnswersRef.once('value')
.then((dataSnapshot1) => {
console.log("Fetching successed.");
if (!dataSnapshot1.exists()) {
return {}
}
var answers = dataSnapshot1.val();
delete answers.lastQuestionId;
return answers;
});
};
I'm trying to get answers from the database.
The problem is that the code return null when I execute dataSnapshot1.val(); even though that answers is not null
Can anyone help me ? Thanks

userIdis not undefined or not null?userAnswersRef.once('value', snapshot => { console.log(snapshot.val()); })