1
import { initializeApp } from "firebase/app";
import { getFirestore } from 'firebase/firestore/lite';

const firebaseConfig = {
  apiKey: "AIzaSyBOK7x5N5UnjY4TDqndzH7l5tvdNIsWFRc",
  authDomain: "todo-app-e3cf0.firebaseapp.com",
  projectId: "todo-app-e3cf0",
  storageBucket: "todo-app-e3cf0.appspot.com",
  messagingSenderId: "940016886081",
  appId: "1:940016886081:web:91686613f16b1b1f8001c0",
  measurementId: "G-JHPC7TP12K"
};

const firebaseApp = initializeApp(firebaseConfig);
const db = getFirestore(firebaseApp);

export default db;

firebase Code

    useEffect(()=>{
        //Get Value from Db
        db.collection('Todos').onSnapshot(Snapshot=>{
            console.log(Snapshot.docs.map(doc=>doc.data().Todo))
            // setTodo(Snapshot.docs.map(doc=>doc.data().Text))
        })
    },[])

Encountered the error while create a todo list To get data from the firestore. The JS code uses On snapshot but wasnt working so console.logged it to see error.

Sairam S
  • 347
  • 1
  • 3
  • 4
  • Does this answer your question? [TypeError: \_firebase\_\_WEBPACK\_IMPORTED\_MODULE\_2\_\_.default.collection is not a function](https://stackoverflow.com/questions/68960910/typeerror-firebase-webpack-imported-module-2-default-collection-is-not-a-fu) – Dharmaraj Dec 27 '21 at 05:58

0 Answers0