I have a store.js file that have the following state and getter:
state: {
isLoggedIn: false,
user: {}
},
getters: {
getUserId: state => state.user.id
},
After a user is logged in, the isLoggedIn becomes true and user is populated with the user's info as seen in image below:
As you can see I have a getter, in the store.js that retrieves the correct ID but when I go to use this in my component, it comes up as undefined.
My component looks like this:
const id = this.$store.getters.getUserId;
console.log(id);
How can I use the value of getUserId in my component?

console.log(id)? This is probably the real issue here (you may have it too early, when it's still undefined). To be sure, you couldconsole.logit on a button@click.