I am experiencing an issue with my function that retrieves data from Firebase. I am able to read the objects, but I cannot access the properties within them.
Whenever I try to parse the content, an error occurs.
Here is the function in question:
this.afAuth.authState.subscribe(data => {
this.itemsList = this.afDatabase.list(`oders/${data.uid}`).valueChanges();
console.log(this.itemsList)
this.itemsList.forEach(data =>{
console.log(data) // this works
console.log(data.name) // this doesn't work (undefined in console)
})
})
This is the JSON OBJECT:
(14) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
0: {hour: 1567395936608, id: 0, name: "Salami", price: "8"}
1: {hour: 1567395936608, id: 9, name: "Suplémment Fromage", price: "8"}
2: {hour: 1567395936608, id: 4, name: "bolo", price: "8"}
3: {hour: 1567395936608, id: 4, name: "bolo", price: "8"}
4: {hour: 1567395985542, id: 4, name: "bolo", price: "8"}
5: {hour: 1567395985542, id: 0, name: "Salami", price: "8"}
6: {hour: 1567395985542, id: 9, name: "Suplémment Fromage", price: "8"}
7: {hour: 1567397849623, id: 6, name: "Dems", price: "15"}
8: {hour: 1567397849623, id: 0, name: "Salami", price: "8"}
9: {hour: 1567397849623, id: 9, name: "Suplémment Fromage", price: "8"}
10: {hour: 1567398309241, id: 0, name: "Salami", price: "8"}
11: {hour: 1567398309241, id: 9, name: "Suplémment Fromage", price: "8"}
12: {hour: 1567402336588, id: 0, name: "Salami", price: "8"}
13: {hour: 1567402336588, id: 9, name: "Suplémment Fromage", price: "8"}
Thank you!