storybook/docs/snippets/svelte/loader-story.js.mdx
2021-07-05 19:19:35 +01:00

23 lines
430 B
Plaintext

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