Reputation: 2515
I am getting value of doc.data()
using get()
.
Console.log(doc.data()) reads:
{ 'abc':
[ { fullname: 'samar chadha',
number: 1,
authid: '8SlzKpqVdXWGQ4dk7zVP23Uh0Pr2' } ] }
I need to fetch the value of number in a variable.
When I try like this doc.data().abc[0].number
it gives error.
How do I fetch this value in a variable ?
This is how it looks in console [here abc is 9-JUN-2020]
Upvotes: 0
Views: 32
Reputation: 83068
The following should do the trick:
const abc = "9-JUN-2020";
const numberVar = doc.data()[abc][0].number;
It uses the square brackets notation
Upvotes: 1