0

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]

enter image description here

1 Answer 1

1

The following should do the trick:

const abc = "9-JUN-2020";
const numberVar = doc.data()[abc][0].number;

It uses the square brackets notation

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.