Trying to learn some vue.js for the framework but having trouble with setting up the basic getDoc app. Terminal errors:
Module not found: Error: Can’t resolve ‘firebase/firestore’ in ‘C:VueProjekttestsrc’
Module not found: Error: Can’t resolve ‘firebase/app’ in ‘C:VueProjekttestsrcfirebase’
Module not found: Error: Can’t resolve ‘firebase/firestore’ in ‘C:VueProjekttestsrcfirebase’
C:VueProjekttestsrcfirebaseinit.js
14:7 error ‘app’ is assigned a value but never used no-unused-vars
App.vue
<template>
<div></div>
</template>
<script>
import db from "./firebase/init.js"
import {doc, getDoc} from "firebase/firestore"
export default {
created(){
this.get_name()
},
methods: {
async get_name(){
const docSnap = await getDoc(doc(db, 'Collection_name', 'Document_name'))
if(docSnap.exists()){
console.log(docSnap.data())
}
else {
console.log('There is no doc to get')
}
}
}
}
</script>
/firebase/init.js
import { initializeApp } from "firebase/app"
import { getFirestore } from "firebase/firestore"
const firebaseConfig = {
...
}
const app = initializeApp(firebaseConfig)
const db = getFirestore()
export default db
I was following a tutorial so I checked for any typos. Checked for posts commenting about SDK 9 but to me, code seems fine.
Pero Ada is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.