0π
β
I guess the state.user
is already a object therefore you donβt need to use JSON.parse
since JSON.parse()
converts the input into a string. The toString() method of JavaScript objects by default returns [object Object], resulting in the observed behavior.
Try removing that such that your code should be
const getters = {
isLoggedIn: (state) => !!state.token,
getUser: (state) => state.user,
getToken: (state) => state.token,
};
Source:stackexchange.com