Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

221
Views
.get() function to get firebase docs "is not a function"

Hey I am trying to get all documents of a certain collection in firebase using:

const userCollectionRef = collection(db, currentUser?.uid)
const snapshot = await userCollectionRef.get()
for (const doc of snapshot) {
    console.log(doc.id)
}

The problem:

TypeError: userCollectionRef.get is not a function

My imports:

import { db } from '../firebase'
import { collection } from 'firebase/firestore'
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

There's a top-level function getDocs() that you can use to fetch multiple documents using a CollectionReference in V9 SDK:

import { collection, getDocs } from "firebase/firestore";

const userCollectionRef = collection(db, currentUser?.uid)

const snapshot = await getDocs(userCollectionRef)

const data = snapshot.docs.map((doc) => ({ id: doc.id, ...doc.data() }))

Checkout the documentation for more information.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!