How to access to the vue store in the asyncData function of nuxt
This worked for me
Store/index.js
...
state: {
loadedPages: []
}
...
Page
async asyncData(context) {
...
console.log(context.store.state.loadedPages)
...
}
You need to get store from context. Reference
asyncData({ app, params, store }) {
var url = `https://myapi/news/${store.state.market}/detail/${params.id}`;
return app.$axios.get(url).then(response => {
return { actu: response.data };
});