Integrating Firebase Database / Firestore with Vue.js Realtime

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;

});

Leave a comment

Your email address will not be published. Required fields are marked *