storybook/docs/snippets/angular/loader-story.ts.mdx
2021-09-03 23:31:04 +01:00

26 lines
407 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(),
}),
],
};
```