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

107
Views
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 answers
Answer question

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 Report

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 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!