How should I get 'full_name' from the object that was created from firebase database snapshot.
const profile_grabber = firebase.database().ref('PublicUserData').orderByChild('full_name');
var returnArr = [];
profile_grabber.once('value', function(snapshot) {
snapshot.forEach(function(childSnapshot) {
var item = childSnapshot.val();
item.key = childSnapshot.key;
returnArr.push(item);
});
}).catch(function(error){
console.log(error.code);
console.log(error.message);
});
console.log(returnArr);
console.log(returnArr[0].full_name);
Console.log() results
//console.log(returnArr);
[] 0: { birth_day: "1996-05-23", full_address: "address 0", full_name: " Udayanga", … }
1: { birth_day: "1997-03-13", full_address: "address 4 ", full_name: "Akila Athauda", … }
2: { birth_day: "1996-10-18", full_address: "address 5 ", full_name: "Chamindu Milan", … }
3: { birth_day: "1996-03-03", full_address: "address 1 ", full_name: "Dilshan Rajapaksha", … }
4: { birth_day: "1997-01-08", full_address: "address 2", full_name: "Gimhana Jayasekara", … }
length: 5 proto: Array(0)
//console.log(returnArr[0].full_name);
Uncaught TypeError: Cannot read property 'full_name' of undefined