Upon examining the code, I noticed an issue with docChanges. It seems to be a function, but when I try to use docChanges().doc.data().userId
, I encounter the error message:
store.js?3bf3:21 Uncaught TypeError: Cannot read property 'doc' of undefined
::UPDATE
Currently, I am facing an error while trying to log in/sign up. Everything works smoothly, except for the this.$router.push('/dashboard')
within the login function. What could be causing this?
Store.js
state: {
currentUser: null,
userProfile: {},
posts: [],
hiddenPosts: []
},
actions: {
clearData({ commit }) {
commit('setCurrentUser', null)
commit('setUserProfile', {})
commit('setPosts', null)
},
fetchUserProfile({ commit, state }) {
fb.usersCollection.doc(state.currentUser.uid).get().then(res => {
commit('setUserProfile', res.data())
}).catch(err => {
console.log(err)
})
}
},
mutations: {
setCurrentUser(state, val) {
state.currentUser = val
},
setUserProfile(state, val) {
state.userProfile = val
},
setPosts(state, val) {
if (val) {
state.posts = val
} else {
state.posts = []
}
},
setHiddenPosts(state, val) {
if (val) {
if (!state.hiddenPosts.some(x => x.id === val.id)) {
state.hiddenPosts.unshift(val)
}
} else {
state.hiddenPosts = []
}
}
}
Error Code on Login
https://i.stack.imgur.com/6kEml.png Login.vue component
<form v-if="showLoginForm" @submit.prevent>
<h1>Welcome Back</h1>
...