How I can use asyncData
in layout or component (forbidden apparently) ?
Because my sidebar component is used in default layout, and I need to use asyncData
to display data from backend.
And if I use Vuex to fetch data... I don't know how I can fetch this with global on every page.
My layout component annotation:
@Component({
components: {
LeftDrawer
},
async asyncData({ app }) {
const latestPosts = await app.$axios.get(`/posts/latest`);
return {
latestPosts: latestPosts.data,
};
}
})