storybook/docs/snippets/vue/loader-story.mdx.mdx
2021-11-03 23:31:14 +00:00

29 lines
577 B
Plaintext

```md
<!-- TodoItem.stories.mdx -->
import { Meta, Story } from '@storybook/addon-docs';
import TodoItem from './TodoItem.vue';
import fetch from 'node-fetch';
<Meta title="Examples/Loader" component={TodoItem} />
<Story
name="Primary"
loaders={[
async () => ({
todo: await (
await fetch("https://jsonplaceholder.typicode.com/todos/1")
).json(),
}),
]}>
{(args, { loaded: { todo } }) => ({
components: { TodoItem },
setup() {
return { args, todo: todo };
},
template: `<TodoItem :todo="todo"/>`,
})}
</Story>
```