import Vuex from 'vuex' import Config from '~/assets/config.js' const createStore = () => { return new Vuex.Store({ state: { homePage: [] }, mutations: { setHomepage (state, obj) { state.homePage = obj } }, actions: { async nuxtServerInit ({ commit }, { app, route }) { console.log('============= Server Init API calls =============') try { console.log('home') const home = await app.$axios.get( Config.wpDomain + Config.api.homePage, { useCache: true } ) commit('setHomepage', home.data) } catch (e) { console.log('error with API', e) } } } }) } export default createStore