I try to bring firebase data
code:
function getClient(key)
{
var client;
db.child("Client")
.on('value', function(snapshot){
client = snapshot.child(key).val()
console.log("1", client)
});
console.log("2", client)
return client;
}
the code returns null.
I did several tests and if it brings the value but when leaving the function .on () does not the value in Client
save any solution?
this is the result in the console: 1- is when you get the values. 2- before returning the client I suppose that they are done in two different processes since first the 2 comes out and then the one