Answer the question
In order to leave comments, you need to log in
Typescript doesn't work with try-catch why?
FILE /store/index.ts
export const getters: GetterTree<RootState, RootState> = {
isLoggedIn: state => (
try {
return state.authUser.id !== null
} catch {
return false
}
)
}
Answer the question
In order to leave comments, you need to log in
export const getters: GetterTree<RootState, RootState> = {
isLoggedIn: state => {
try {
return state.authUser.id !== null
} catch {
return false
}
}
}
but betterexport const getters: GetterTree<RootState, RootState> = {
isLoggedIn: state => !!state?.authUser?.id
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question