storybook
storybook copied to clipboard
Support for asyncData() method
Is your feature request related to a problem? Please describe.
Currently you can't load data using asyncData(). I understand that Storybook doesn't work the same as Nuxt, but we should be able to at least mock the usage of asyncData() so we can create "page components" in storybook. For example I'm trying to include and example in our storybook of how to do a lazy-loading page correctly.
Describe the solution you'd like
Have asyncData() work like it does in Nuxt page components. Seems fine if it works the same as fetch() but with context as a parameter.
Describe alternatives you've considered
Using fetch but it doesn't have access to context as a parameter so it's not as accurate.
Yeah this is preventing our use of prismic content within storybook which is a bit frustrating
Using
fetchbut it doesn't have access tocontextas a parameter so it's not as accurate.
I recently had the same problem and found that you can access the context via this.$nuxt.context in a fetch hook. I have not found any documentation for this so it might be an unsupported way of doing things that might break in the future :man_shrugging:
v4 of this module is no longer actively supported. Please try the newest version and open an new issue if the problem persists. Thank you for your understanding.