The following code snippet is designed to retrieve an object from Firebase, specifically an array
.
this.item2 = this.af.object('/profiles/' + this.username + '/followers');
this.subscription5 = this.item2.subscribe(item => {
console.log(JSON.stringify(item) + " followers number 98989899889");
if(Object.keys(item)[0] == '$value') {
this.followers = 0;
}
else {
this.followers = item.length;
}
})
This depicts the structure of my firebase database:
"profiles" : {
"Jencuts" : {
"address" : "34 school st dedham ma",
"bio" : "I love cuts. Cuts are my jam i am jencuts who are you?",
"email" : "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="733b1b141b19191933444546475d101c">[email protected]</a>",
"followers" : [ {
"Jencuts" : "gxPYJNXcOagJr7gxNzPLtUY9aZF2"
} ],
"password" : "Kjhvjjjjbcv",
"price" : "$$$$",
"rating" : {
"five" : 0,
"four" : 0,
"one" : 0,
"three" : 0,
"two" : 0
},
"username" : "Jencuts"
},
....
Jencuts
corresponds to the username (this.username
).
The expected outcome was to receive the followers
array, but instead, it indicates that nothing was found and returns {$value:null}
.