$route usage in vue2 composition-api #526
Answered
by
posva
tcarac
asked this question in
Help and Questions
-
How can I access $route in store with composition-api vue2 ? {
actions:{
setUserToken(token) {
localStorage.setItem("token", token);
this.$router.push("/");
},
}
} Usage: {
setup() {
const { setUserToken } = useMainStore();
const { mutate, loading, onError, onDone } = useMutation(LoginMutation);
const snackbar = reactive({
show: false,
text: "Authentication Error",
});
onError((e) => {
snackbar.text = e.message;
snackbar.show = true;
});
onDone(({ data }) => {
setUserToken(data.login);
});
const onSignIn = (payload) => {
mutate(payload);
};
return { onSignIn, loading, snackbar };
},
} |
Beta Was this translation helpful? Give feedback.
Answered by
posva
Jun 6, 2021
Replies: 1 comment
-
This is one of the plugins examples: https://pinia.esm.dev/core-concepts/plugins.html#adding-new-external-properties |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
posva
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is one of the plugins examples: https://pinia.esm.dev/core-concepts/plugins.html#adding-new-external-properties