storybook/docs/snippets/vue/loader-story.3.js.mdx
2021-11-09 01:41:54 +00:00

32 lines
689 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/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Examples/Loader',
component: TodoItem,
};
export const Primary = (args, { loaded: { todo } }) => {
return {
components: { TodoItem },
setup() {
return { args, todo: todo };
},
template: `<TodoItem :todo="todo"/>`,
};
};
Primary.loaders = [
async () => ({
todo: await (await fetch('https://jsonplaceholder.typicode.com/todos/1')).json(),
}),
];
```