The Nuxt.js application I am working on involves initializing a variable in a Vuex module that uses Axios in its actions.
store/program.js
let program_url = 'programs/';
export const actions = {
async programList({commit}) {
await this.$axios.$get(program_url).then((response) => {
commit("ALL_PROGRAMS", response);
});
},
The challenge I am encountering is that this variable is dependent on a state variable from another Vuex module. I am aiming to create a variable named
program = <dynamic_id_from_another_vuex_module>/program
in store/program.js.
The other Vuex file is store/university.js
export const state = () => ({
settings: [],
id: null
});
export const getters = {
getId(state) {
return state.id;
}
};
So, how can I achieve something like the following in my store/program.js?
let program = store.getters['university/getId'] + 'program';