This is a tricky question @lukasborawski
It is possible but kind of tricky since you need to pass the context to the asyncData method, here how you can do it:
async mounted() {
const data = await this.$options.asyncData(this.$root.$options.context)
console.log('data', data)
}
this.$root.$options.context is actually the last context given to asyncData, but keep in mind that redirect won't work for example.
PS: You don't want to call asyncData from created hook since it's run on both client-side and server-side, you want to use it on client-side only (beforeMount and mounted).
REALLY useful workaround @atinux 馃憤
Hi guys,
This works after nuxt generate command??
Well that should be @roqsantacruz
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
This is a tricky question @lukasborawski
It is possible but kind of tricky since you need to pass the context to the
asyncDatamethod, here how you can do it:this.$root.$options.contextis actually the last context given toasyncData, but keep in mind thatredirectwon't work for example.PS: You don't want to call
asyncDatafromcreatedhook since it's run on both client-side and server-side, you want to use it on client-side only (beforeMountandmounted).