I'm super new to nuxt and have picked up a large project. I can't work out how other views are doing it, but I want to run an axios on page load, could someone help me?
The way this project is structured is it has a store folder (guessing this is vuex), and get a getter.js, mutations.js, index.js, state,js, and actions.js (apologies if this is the natural way) not sure if the way my project does it is a custom design pattern or if its just the goto way with nuxt / vuex
So far I have tried this,
computed: {
plans: 'accountBilling/fetch',
},
But I believe this is for the getters.js file?
I have an actions.js file, and want to call and receive the response from fetch on page load?
export default {
async fetch({ commit }, { account_id }) {
return await this.$axios.get(`/accounts/billing/plans`)
.then(response => { commit('setPlans', response.data); response.data })
.catch(error => { throw error })
},
}
store
folder and code ofstate.js
? – Andrew Vasilchuk