Get Comments
Retrieve comments for a post or story. The backend uses api/Comment with query params.
Endpoint
GET /api/Comment?contentId={contentId}&contentType=Post&userId={userId}&page=1&pageSize=20
Authentication: Required
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| contentId | GUID | Yes | Post or story ID |
| contentType | string | Yes | Post or Story |
| userId | GUID | No | Current user ID (for reaction info) |
| page | number | No | Page number (default: 1) |
| pageSize | number | No | Comments per page (default: 20) |
Response
Success (200 OK)
{
"success": true,
"data": [
{
"id": "comment-id",
"content": "Great post!",
"author": {
"id": "user-id",
"fullName": "John Doe",
"username": "johndoe"
},
"reactions": {
"like": 2,
"total": 2
},
"repliesCount": 1,
"replies": [
{
"id": "reply-id",
"content": "I agree!",
"author": { ... }
}
],
"createdAt": "2024-01-01T00:00:00Z"
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 50,
"totalPages": 3
}
}
Example
const response = await fetch(
`http://localhost:5000/api/Comment?contentId=${postId}&contentType=Post&userId=${userId}&page=1&pageSize=20`,
{ headers: { 'Authorization': `Bearer ${token}` } }
);
const data = await response.json();
Get comment reactions
GET /api/Comment/{commentId}/reactions?requestingUserId={userId}