storybook/docs/snippets/vue/loader-story.3.js.mdx
2022-11-17 16:33:22 +01:00

32 lines
701 B
Plaintext

```js
// TodoItem.stories.js
import TodoItem from './TodoItem.vue';
import fetch from 'node-fetch';
export default {
/* 👇 The title prop is optional.
* See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Examples/Loader',
component: TodoItem,
};
export const Primary = {
render: (args, { loaded: { todo } }) => ({
components: { TodoItem },
setup() {
return { args, todo: todo };
},
template: '<TodoItem :todo="todo" />',
}),
loaders: [
async () => ({
todo: await (await fetch('https://jsonplaceholder.typicode.com/todos/1')).json(),
}),
],
};
```