I want to access vuex store specifically getters from fetch hook.
Here is my getters I'm loading using mapGetters inside order page
computed: {
...mapGetters("auth", ["authUser"])
},
Here is apollo call from fetch hook and I'm trying to provide authUser.id as a variable which is provided by authUser getter from vuex store.
async fetch() {
console.log("fetch order is called");
const orderInput = {
userId: this.authUser.id,
orderStatus: "PENDING"
};
const response = await this.$apollo.query({
query: getOrdersByUserIdQuery,
variables: { orderInput }
});
this.orders = response.data.getOrderByUserId.orders;
console.log("getOrderResponse", response);
},
But, it fails to load the authUser from the store in initial page load.
I am curious to know If my steps are correct or not. If this is not correct what are the other alternatives that can I follow?
...mapGetters(["auth","authUser"])authUserin your store.