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

108
Vistas
can't display data from firestore

I'm trying to display the data from firestore. But I'm getting an error as following.

WEBPACK_IMPORTED_MODULE_1__firebase_init.a.collection is not a function" error_image

what I've done

First, I created init.js in order to initialize Firebase and begin using the SDKs in my webapp. I imported several modules but not sure if I neeed them for my todo-list app.

import * as firebase from "firebase/app";
import { initializeApp } from "firebase/app";
import { getAnalytics } from "firebase/analytics";
import { getfirestore, where, query } from 'firebase/firestore';
import { getFirestore, collection, getDocs } from 'firebase/firestore/lite';

const firebaseConfig = {
  apiKey: *****,
  authDomain: *****
  projectId: *****
  storageBucket: *****
  messagingSenderId: *****
  appId: *****,
  measurementId: *****
};



firebase.initializeApp(firebaseConfig);
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
// const db = getFirestore(app);

export default getFirestore(app);

Next, in my index.vue file, I imported db from init.js, which I created above. And I'm trying to console.log the data from firebase but it is not working..

import db from '@/firebase/init'
...
created(){
    db.collection('smoothies').get()
    .then(snapshot => {
      snapshot.forEach(doc => {
        console.log(doc)
      })
    })
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Try removing this line firebase.initializeApp(firebaseConfig);

You initialize firestore on the next line. const app = initializeApp(firebaseConfig);

You can find more instructions on how to initialize firestore here: https://www.npmjs.com/package/firebase

about 4 years ago · Juan Pablo Isaza Denunciar

0

The issue seems your import method which is import db from '@/firebase/init'

Try this by importing db as follows,

 import { db } from 'firebase/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