How to access Store A action in Store B? #1500
Unanswered
sajjadalis
asked this question in
Help and Questions
Replies: 2 comments
-
I have managed to access the action. I wonder if that's the correct way. import { defineStore } from "pinia";
import { useItemStore } from "@/stores/items";
export const usePostStore = defineStore({
id: "posts",
state: () => ({
post: {},
itemStore: useItemStore()
}),
actions: {
createPost() {
this.post = { title: "Post" };
this.itemStore.fetchItems();
},
},
}); |
Beta Was this translation helpful? Give feedback.
0 replies
-
This is the correct way: https://pinia.vuejs.org/cookbook/composing-stores.html#composing-stores |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is store A.
This is store B.
I'm getting this error.
Help would be really appreciated.
Beta Was this translation helpful? Give feedback.
All reactions