storybook/docs/snippets/web-components/loader-story.ts.mdx
Kyle Gach 45d053b1bc Address comments
- Add missing snippet
2023-01-13 08:24:29 -07:00

27 lines
517 B
Plaintext

```ts
// TodoItem.stories.ts
import type { Meta, StoryObj } from '@storybook/web-components';
import fetch from 'node-fetch';
const meta: Meta = {
title: 'Examples/Loader'
component: 'demo-todo-item',
render: (args, { loaded: { todo } }) => TodoItem({...args, ...todo}),
};
export default meta;
type Story = StoryObj;
export const Primary: Story = {
loaders: [
async () => ({
todo: await (
await fetch('https://jsonplaceholder.typicode.com/todos/1')
).json(),
}),
],
};
```