lcl code base
lcl code base

Reputation: 101

data not fetching from firestore in react native

i created a collection in firestore called user and added a document and gave it 7 fields, but when i try fetching the data back using onSnapshot it does not return back any data. this is the collection

enter image description here

this is my code:

firestore()
          .collection('user')
          .doc('LCqSZXM17WUWiWFahyj6')
          .onSnapshot((row) => {
            console.log(row.data());
          });

in the console it logs an empty array

thanks in advance!!!

Upvotes: 0

Views: 92

Answers (1)

MJ Studio
MJ Studio

Reputation: 4611

You need to include more information. Anyway, do you check your access rule of the Firestore database?

const doc = db.collection('cities').doc('SF');

const observer = doc.onSnapshot(docSnapshot => {
  console.log(`Received doc snapshot: ${docSnapshot}`);
  // ...
}, err => {
  console.log(`Encountered error: ${err}`);
});

The above code is official docs code. Check error callback first.

Upvotes: 1

Related Questions