Edit: I made an error here ^^ !https://i.sstatic.net/0QGRx.png
firebase.js?5b23:11 Uncaught TypeError: app.database is not a function
at eval (firebase.js?5b23:11)
at Object../src/components/firebase/firebase.js (app.js:3496)
at __webpack_require__ (app.js:679)
at fn (app.js:89)
at eval (selector.js?type=script&index=0!./src/components/front-end/Getstarted.vue:3)
at Object../node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/components/front-end/Getstarted.vue (app.js:2791)
at __webpack_require__ (app.js:679)
at fn (app.js:89)
at eval (Getstarted.vue?5f4d:1)
at Object../src/components/front-end/Getstarted.vue (app.js:3552)
While attempting to move the firebase code into a separate file instead of the .vue file, I encountered issues. It functions as intended when placed within the vue file, but transferring it seems to be problematic.
<script>
import Firebase, { functions } from 'firebase'
import conf from '../firebase/firebase'
let config = {
apiKey: ''
authDomain: ''
databaseURL: ''
projectId: ''
storageBucket: ''
messagingSenderId: ''
}
let app = Firebase.initializeApp(config)
let db = app.database()
let booksRef = db.ref('books')
(dashboard.Vue)
*this is how it is in my vue file *
I have 2 javascript files One with:
import config from './firebaseConfig'
class Firebase {
constructor () {
firebase.initializeApp(config)
}
}
let db = app.database()
let booksRef = db.ref('books')
export default Firebase()
(firebase.js)
and one with:
let config = {
apiKey: '',
authDomain: '',
databaseURL: '',
projectId: '',
storageBucket: '',
messagingSenderId: '',
appId: ''
}
export default (config)
(firebaseConfig.js)
My folder structure looks like this:
components
|firebase
||firebase.js
||firebaseConfig.js
|backend
||Dashboard.vue
Upon loading the webpage, it displays as a blank page. Seeking guidance on restructuring this setup correctly. Feel free to ask if anything is unclear.