How can I get a data as a string?
getData() {
firebase.database().ref('users/USER_UID/username').on('value', snap => snap.val())
}
console.log(this.getData())
Why is it that when I do this, I get undefined? The .ref()
is a direct connection to a key. I just want to get its value.
I don't want to do this:
getData() {
firebase.database().ref('users/USER_UID/username').on('value', snap => console.log(snap.val()))
}
console.log(this.getData())