I'm adding some keys from a firebase database to an array, but it remains empty. The code is the following:
ref.once("value")
.then(function(snapshot) {
snapshot.forEach(tag =>{
tags1.push(tag.key);
})
});
I checked for the value of tag.key
by printing it on the console inside the forEach
, and all the keys are printed correctly.
Then, I've tried to perform a forEach
on the tags1
array, but it doesn't enter the for
. I've printed the length of tags1
and it is 0.
I've declared tags1
this way:
let tags1 = [];
I've also tried to declare it as Array<any>
, but it keeps staying empty.