Cannot read properties of null (reading 'includes') Error - After login in NuxtJs
m7salam opened this issue · comments
Hello
I am using NuxtJs and keeps getting this weird error I tried moving in many places my code but it doesn't seem to work I'm using the persistent option to true
Everytime first time login I get this error
after refreshing the page it works as it should but everytime first time logging in it gives this error
I'm using the below code in default.vue layout folder
if (this.$store.state.auth.user.companies_usernames.includes('company')) {
this.$gates.setRoles(['superuser'])
this.$gates.setPermissions(['all'])
} else {
this.$store
.dispatch(
'user/getCurrentUser',
this.$store.state.auth.user.company_username
)
.then(() => {
this.$gates.setRoles([this.$store.state.user.currentUser.role])
this.$gates.setPermissions(
this.$store.state.user.currentUser.permissions
)
})
}
Hi @m7salam Did you manage to solve your problem?
I managed to solve it, the problem was that I was passing a null property. Thanks