Getting all documents from one collection in Firestore

Hi I’m starting with javascript and react-native and I’m trying to figure out this problem for hours now. Can someone explain me how to get all the documents from firestore collection ?

I have been trying this:

async getMarkers() {
  const events = await firebase.firestore().collection('events').get()
    .then(querySnapshot => {
      querySnapshot.docs.map(doc => {
        console.log('LOG 1', doc.data());
        return doc.data();
      });
    });
  console.log('LOG 2', events);
  return events;
}

Log 1 prints all the objects(one by one) but log 2 is undefined, why ?

93 thoughts on “Getting all documents from one collection in Firestore”

  1. Right here is the perfect website for anyone who really wants to find out about
    this topic. You know a whole lot its almost hard to argue with you (not that I personally
    will need to…HaHa). You certainly put a brand new spin on a
    subject that’s been discussed for years. Excellent stuff, just excellent!

    Reply
  2. I really love your blog.. Great colors & theme. Did you build this site yourself?
    Please reply back as I’m attempting to create my own personal
    website and would like to know where you got this from or what the theme is called.
    Appreciate it!

    Reply
  3. hi!,I really like your writing so much! share we be in contact more approximately your post
    on AOL? I require an expert on this space to solve my problem.
    May be that’s you! Having a look forward to see you.

    Reply
  4. Do you have a spam issue on this site; I also am a blogger, and I was
    wondering your situation; many of us have developed some nice procedures and
    we are looking to swap strategies with others,
    please shoot me an email if interested.

    Reply
  5. This design is spectacular! You certainly know how to keep a reader entertained.
    Between your wit and your videos, I was almost moved to start
    my own blog (well, almost…HaHa!) Fantastic job.
    I really enjoyed what you had to say, and more than that, how you presented it.
    Too cool!

    Reply
  6. Wonderful beat ! I wish to apprentice at the same time as you amend your site, how could i subscribe for a weblog website?

    The account helped me a acceptable deal. I had been a little bit familiar of this your broadcast offered bright
    clear idea

    Reply
  7. This design is incredible! You most certainly know how to keep a reader
    entertained. Between your wit and your videos, I was almost moved to start my own blog
    (well, almost…HaHa!) Wonderful job. I really loved what
    you had to say, and more than that, how you presented it. Too cool!
    cheap flights http://1704milesapart.tumblr.com/ cheap flights

    Reply
  8. Greetings! I know this is somewhat off topic but I was wondering
    which blog platform are you using for this site? I’m
    getting fed up of WordPress because I’ve had issues with hackers and I’m looking at alternatives for another platform.
    I would be great if you could point me in the direction of a good platform.
    scoliosis surgery https://0401mm.tumblr.com/ scoliosis surgery

    Reply
  9. i need a loan now direct lender, i need loan please help me. i need loan need loan need a loan now need loan but i am not working, credit union cash advance loans, cash advance loans, cash advance, united cash advance loans. Money study of those investment, internationally active.

    Reply

Leave a Comment