Answer the question
In order to leave comments, you need to log in
How to pass parameter to vuex?
There is a component that I get to through the vue router, I want to take the $router.url parameter and call an axios request that is located in store.js for example
async GET_INDEX_ARTICLES({ commit }) {
return axios("https://rest.api/articles?_sort=created_at:desc&publish=true&_limit=$router.url", {
method: "GET",
})
.then((response) => {
commit("SET_INDEX_ARTICLES", response.data);
})
.catch((error) => {
console.log("Exception: ", error);
commit("SET_ERROR", error.true);
});
},
Answer the question
In order to leave comments, you need to log in
Move the router instance to a separate file.
Connect it in the vuex module where you need it:
And use it.
import router from '@/router'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question