Asynchronous access to an array in Firebase
Here is my code:
Here is what the console gives me:

As you can see, I cannot access the array. Do you have any idea of how I could do this?
Thanks in advance.
var userRef = new Firebase("https://awesome.firebaseio.com/users/");
var tokenRef = userRef.child(key+'/tokens');
tokenRef.once('value', function(snapshot){
var userTokenSync = $firebase(tokenRef);
var userTokens = userTokenSync.$asArray();
console.log(userTokens);
console.log(userTokens[0]);
for(var i=0, len = userTokens.length; i < len; i++) {
console.log(userTokens[i]);
}
console.log('done');
})
This code gets the tokens of a user from firebase, and I just want to browse the tokens array.Here is what the console gives me:

As you can see, I cannot access the array. Do you have any idea of how I could do this?
Thanks in advance.
Comments
Post a Comment