Hi I need some help with these it says that
Uncaught (in promise) TypeError: Object(...)(...).once is not a function at eval (store.js?07a4:42:1) at eval (index-6de4cbb9.js?4d2d:2453:1)
Here's my code:
import { firebaseAuth, firebaseDb } from 'boot/firebase'
import { createUserWithEmailAndPassword, signInWithEmailAndPassword,onAuthStateChanged } from "firebase/auth";
import { ref, set } from "firebase/database";
const state = {
}
const mutations = {
}
const actions = {
registerUser({}, payload) {
createUserWithEmailAndPassword(firebaseAuth, payload.email, payload.password)
.then(response => {
console.log(response)
const userId = firebaseAuth.currentUser.uid
set(ref(firebaseDb, 'users/' + userId), {
name: payload.name,
email: payload.email,
online: true
})
}).catch(error => {
console.log(error.message)
})
},
loginUser({}, payload) {
signInWithEmailAndPassword(firebaseAuth, payload.email, payload.password)
.then(response => {
console.log(response)
}).catch(error => {
console.log(error.message)
})
},
Here's the part that is error:
handleAuthStateChanged() {
onAuthStateChanged(firebaseAuth, user => {
if (user) {
// User is signed in, see docs for a list of available properties
// https://firebase.google.com/docs/reference/js/firebase.User
const userId = firebaseAuth.currentUser.uid
ref(firebaseDb, 'users/' + userId).once('value', snapshot => {
console.log('snapshot: ', snapshot)
})
// ...
} else {
User is signed out
// ...
}
})
}
}
const getters = {
}
export default {
namespaced: true,
state,
mutations,
actions,
getters
}
i dont get it i still received this kind of error
<script>
import { mapActions } from "vuex"
export default {
methods: {
...mapActions('store', ['handleAuthStateChanged'])
},
mounted(){
this.handleAuthStateChanged()
}
}
</script>
this is my App.vue script