Skip to content

Using 2 stores inside vue component in Options API (getActivePinia was called with no active Pinia error) #1900

Discussion options

You must be logged in to vote

I have figured it out. I was using another alert.ts store inside my authentication.ts store, but globally.

What helped me figure it out is this: #664 (comment)

So in example:

import { alertStore } from '@/stores/alert';
const aStore = alertStore();  // **having this as global variable, was causing the problem**

interface State {
	status: object | null;
	user?: any;
	firstName: string;
	rememberMe: boolean;
	email: string;
}
export const authenticationStore = defineStore('authUser', {
	state: (): State => ({
			email: '', // have to save it in case of 2fa
	}),
	getters: {
		getEmail: (state) => state.email,
	},
	actions: {
		async login(data: object) {
			aStore.danger('Hello there'); 
		…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Uraharadono
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant