# RequestCommentsCallback Function

> Callback function for requests retrieving an array of CommentedText objects.

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Function
- **Introduced:** 30.0
- **Path:** DS Server > Reference > JavaScript API > RequestCommentsCallback Function
- **369 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/requestcommentscallback/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/requestcommentscallback/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/requestcommentscallback/llms-full.txt

---

### Description

Callback function for requests retrieving an array of [CommentedText](https://docs.textcontrol.com/ds-server/reference/javascript/commentedtext/llms-full.txt) objects.

### Syntax

```javascript
function(<CommentedText[]> comments)
```

### Examples

The following example demonstrates `RequestCommentsCallback` in a practical document-editing workflow. Callback function for requests retrieving an array of CommentedText objects.

```javascript
function onTxError(error) {
    console.error("TX Text Control error:", error.msg);
    error.handled = true;
}

function requestCommentsCallback(comments) {
    console.log("comments:", comments);
}

TXTextControl.textParts.getMainText(function(mainText) {
    const comments = mainText.comments;
    comments.getItem(function(commentedText) {
        if (!commentedText) {
            console.warn("No commented text is available at the current input position.");
            return;
        }
    
        commentedText.getReplies(requestCommentsCallback, onTxError);
    }, onTxError);
}, onTxError);
```

---

## Nearby

- **Previous:** [RequestCommentCallback Function](https://docs.textcontrol.com/ds-server/reference/javascript/requestcommentcallback/llms-full.txt)
- **Next:** [RequestDateFormFieldCallback Function](https://docs.textcontrol.com/ds-server/reference/javascript/requestdateformfieldcallback/llms-full.txt)
