javascript - Firebase: Push Item in If Statement -


i'm trying work out why function isn't pushing item object availableproviders array within if statement.

serviceproviders.on('value', function(snapshot) {   var availableproviders = [];    snapshot.foreach(function(childsnapshot) {     var key = childsnapshot.key();      providers.on('value', function(snap) {       if (snap.haschild(key)) {         var item = snap.child(key);         availableproviders.push(item);       }     });   });    console.log(availableproviders); }); 

for reason console.log @ end returns empty array.

any reason why item isn't being pushed. appreciated. in advance!


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -