storybook/docs/snippets/angular/loader-story.ts.mdx
2021-08-28 01:52:57 +01:00

26 lines
403 B
Plaintext

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