Firebase.js
import firebase from “firebase/app”;
import “firebase/firestore”;
const db = firebase.firestore();
// Function to fetch data from Firestore
export const getTodos = async () => {
const snapshot = await db.collection(“todos”).get();
return snapshot.docs.map(doc => doc.data());
};
index.vue
import { getTodos } from “./firebase”;
getTodos().then(todos => {
this.todos = todos;
});