Storybook: Storybook unable to access fetch hook

Created on 11 Aug 2020  路  3Comments  路  Source: nuxt-community/storybook

Version

@nuxtjs/storybook: 1.2.0/2.0.0
nuxt: 2.14.1

Reproduction Link

https://codesandbox.io/s/nuxt-storybook-fetchtest-44tml?file=/components/FetchTest.vue

Steps to reproduce

  1. Create a Nuxt.js storybook project.
  2. Create a component and story with async fetch hook.
  3. Storybook fails to run fetch hook, cannot access $fetch or $fetchState.

What is Expected?

@nuxtjs/storybook should have access to async fetch hook.

What is actually happening?

@nuxtjs/storybook does not run fetch hook, fails silently. Trying to run $fetch() on button click, or conditionally render markup with $fetchState throws error: "Property or method "$fetch" is not defined on the instance but referenced during render"

bug

Most helpful comment

This will support in v2.1.0

All 3 comments

I've ran into this with components that rely on fetch() hook/method for data. I understand that Storybook isn't Nuxt, but it would be great if there was a way to just have the fetch() hook run like it was on mounted() (so not SSR'd) so the data would come in at least.

Having a way to stub in nuxt-link would be useful too.

This will support in v2.1.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Sananes picture Sananes  路  3Comments

macieklad picture macieklad  路  4Comments

gabimor picture gabimor  路  4Comments

ponnex picture ponnex  路  5Comments

altryne picture altryne  路  3Comments