Home

Issue: 1031

Fetching data via store server side not working

[issue link]

Im sure this has been asked before but i cant for the life of me figure out whats going on

this code in the page

fetch ({ store }) {
 const response = await axios.get(dataUrl);
 console.log(response.data)
 store.commit("SET_SECTIONS", response.data);
}

and yet somehow this doesn’t work

fetch ({store}) {
 store.dispatch('fetchSections')
}

where in the store the action is doing the same thing

 async fetchSections({ commit, getters }) {
    const response = await axios.get(dataUrl);
    console.log(response.data)
    commit("SET_SECTIONS", response.data);
  }

the console log is the same for both, but for some reason the one where the fetc calls the action isnt populating the store?

Any ideas?

This question is available on Nuxt.js community (#c903)