Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

213
Vistas
.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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda