I guess this is not a Firebase question as much as it is a callback syntax question:
I want the function changeName to go to Firebase database and replace the value of "t" with a value that is a child of "t" in the database.
function changeName (t) {
return (
t.replace(t, firebase.database().ref(`langs/${t}`).once('value', snap => snap.val().name))
)
}
But I get [object Promise]
.
The code does work when I put an alert()
method inside the snap arrow function, so I know the access to the value is fine. I just couldn't figure out how to get the value as a string of text for the replace()
method.