ondata
Description
The event is triggered to fetch comments dataUsage
ondata?: (value: string | number) => 
  | {
      id?: string | number;
      content: string;
      author?: {
        id: string | number;
        name?: string;
        avatar?: string;
        color?: string;
      };
      user?: string | number;
      date?: Date;
      format?: "text" | "markdown" | FormatComponent;
    }[]
  | Promise<{
      id?: string | number;
      content: string;
      author?: {
        id: string | number;
        name?: string;
        avatar?: string;
        color?: string;
      };
      user?: string | number;
      date?: Date;
      format?: "text" | "markdown" | FormatComponent;
    }[]>;
Parameters
- 
value– (required) the identifier used to fetch comments data- Can be a 
stringornumber, depending on how the widget was initialized - Often represents a stream ID, post ID, or any key used to load the corresponding comments
 
 - Can be a 
 - 
Return value – the function must return either:
- – an array of 
commentobjects, or Promise<comment[]>– a promise that resolves to an array of comment objects.
 - – an array of 
 
Fields of the comment object:
id– (optional) unique identifier of the commentcontent– (required) text of the commentauthor– (optional) embedded author object:id– (required) unique identifier of the authorname– (optional) display name of the authoravatar– (optional) URL of the author's avatarcolor– (optional) color used to style the author's comments
user– (optional) ID of a user from theuserslistdate– (optional) timestamp when the comment was postedformat– (optional) rendering format:"text" | "markdown" | FormatComponent
Examples
Loading comments through REST helper
<script>
  import { RestURL } from "@svar-ui/lib-data-provider";
  import { Comments } from '@svar-ui/svelte-comments';
  const url = new RestURL("https://some.com/api/comments");  
</script>
<Comments ondata={v => url.get(v)} />
This example demonstrates how to load comments using the REST helper. The url.get(v) method fetches comments from the specified API.
Converting ID of comment's stream to data
<script>
  import { Comments } from '@svar-ui/svelte-comments';
  const ondata = (v) => {
    return fetch(`/api/comments/${v}`).then(r => r.json());
  };
</script>
<Comments value={1} {ondata} />
In this example, the ondata function fetches comments based on the stream ID. It returns a promise that resolves to an array of comments.