0

I have below code which getting data from the firestore directly from angular. as you can look console.log(data.city); where I have document reference of city. so how could I access data from document reference in angular?

code image

1 Answer 1

3

Document references in Firestore won't give you data right away. You'll have to use that document reference and get data from firebase.

It is just like getting data manually referencing a document. For instance,

this.afs.collection('users').doc('doc_id').get().then(result => console.log(result.data()));;//if you want to access a specific document

if you already have a reference (like city in your case),

data.city.get().then(result => console.log(result.data()));

You can use :any datatype to data object if it throws any invalid reference exception

Hope this helps!!

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.