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

378
Vistas
can you help me solve this collection.get() function error?

I was trying to use a database in my project, so i imported 'collection' to use it this is my code:

import { initializeApp } from "https://www.gstatic.com/firebasejs/9.0.2/firebase-app.js";
import { getAuth, createUserWithEmailAndPassword, signOut, signInWithEmailAndPassword, onAuthStateChanged } from "https://www.gstatic.com/firebasejs/9.0.2/firebase-auth.js";
import { getFirestore, collection } from "https://www.gstatic.com/firebasejs/9.0.2/firebase-firestore.js";

const firebaseConfig = {
  apiKey: "AIzaSyC3GLIN5TBmCDoTfy0dEOgOdvVvqNw-ric",
  authDomain: "auth-project-38aaa.firebaseapp.com",
  projectId: "auth-project-38aaa",
  storageBucket: "auth-project-38aaa.appspot.com",
  messagingSenderId: "431888894254",
  appId: "1:431888894254:web:71bb9b250fbb8a21edd2bf",
  measurementId: "G-6BBPCJ3814"
};

const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
const db = getFirestore(app);

// get data
collection(db, 'guides').get().then(snapshot => {
    console.log(snapshot.docs);
});

but instead of showing me the 'snapshot.docs' in the console it gives me this message:

auth.js:20 Uncaught TypeError: collection(...).get is not a function
    at auth.js:20

please help me to solve this problem.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You're importing the new modular/functional SDK, where the equivalent of collectionRef.get() is actually:

getDocs(collection(db, 'guides')).then(snapshot => {
  ...

The Firebase documentation itself has all been updated to contain both the older snippets, and snippets for the new API, such as in this case the documentation on getting multiple documents.

But if you're new to Firebase and using code from other places, those might not have both snippets styles yet. In that case it might be easier to start by importing the compat libraries from the new SDKs, while you're figuring out how everything works. If you just want to do that for Firestore, it'd be:

import 'firebase/compat/firestore';
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