I got a function that accesses to a database on firebase and I get the data doing this:
private chargeData() {
let ref = firebase.database().ref('users/' + this.auth.uid);
ref.on('value', function (snapshot) {
console.log(snapshot.val());
}, function (error) {
console.log('Charge data error, ', error.code);
});
}
I'm using ionic 3 so I want to keep all that I received on a local variable to show it on the HTML view but I don't know how. I try to initialize a variable like this.userData = snapshot.val();
but an error occurred "This is null".