storybook icon indicating copy to clipboard operation
storybook copied to clipboard

Support for asyncData() method

Open drewbaker opened this issue 5 years ago • 2 comments

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.

drewbaker avatar Dec 01 '20 11:12 drewbaker

Yeah this is preventing our use of prismic content within storybook which is a bit frustrating

gavmck avatar Apr 28 '21 16:04 gavmck

Using fetch but it doesn't have access to context as 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:

lilioid avatar Jul 29 '21 11:07 lilioid

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.

tobiasdiez avatar May 01 '24 07:05 tobiasdiez