I am trying to make a collection as seen in the code below. But trying to do it is giving me the error:
Unhandled Rejection (TypeError): _firebase_firebase_config__WEBPACK_IMPORTED_MODULE_0 __. Db.collection is not a function
My notes from where I call the DB
import { db } from "../firebase/firebase-config";
export const startNewNotes = () => {
return async ( dispatch, getState ) => {
const { uid } = getState().auth;
const newNote = {
title: '',
body: '',
date: new Date().getTime()
}
const doc = await db.collection(`${uid}/journal/notes`).add( newNote)
console.log(doc)
}
}
This is the firebase file in which I am calling firestore, I also tried importing firebase and doing firebase.firestore
and it doesn't let me
import 'firebase/firestore';
import 'firebase/auth';
import { initializeApp } from "firebase/app";
import { getFirestore } from 'firebase/firestore';
import { GoogleAuthProvider } from 'firebase/auth';
// Your web app's Firebase configuration
const firebaseConfig = {
apiKey: "xx",
authDomain: "xx",
projectId: "xx",
storageBucket: "xx",
messagingSenderId: "xx",
appId: "xx"
};
// Initialize Firebase
initializeApp(firebaseConfig);
const db = getFirestore();
const googleAuthProvider = new GoogleAuthProvider();
export{
db,
googleAuthProvider
}