Skip to main content

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

ParameterTypeRequiredDescription
contentIdGUIDYesPost or story ID
contentTypestringYesPost or Story
userIdGUIDNoCurrent user ID (for reaction info)
pagenumberNoPage number (default: 1)
pageSizenumberNoComments 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}

Next Steps