storybook/docs/snippets/svelte/loader-story.js.mdx

18 lines
350 B
Plaintext

```js
// TodoItem.stories.js
import fetch from 'node-fetch';
import TodoItem from './TodoItem.svelte';
export const Primary = (args, { loaded: { todo } }) => ({
Component: TodoItem,
props: {...args, ...todo},
});
Primary.loaders = [
async () => ({
todo: (await fetch('https://jsonplaceholder.typicode.com/todos/1')).json(),
}),
];
```