Comment count API endpoint

This commit is contained in:
Imbus 2024-03-23 00:23:29 +01:00
parent 5eeed1e8bc
commit 85c2161a4d
4 changed files with 56 additions and 2 deletions

View file

@ -95,6 +95,17 @@ export async function getComments(
return data;
}
/**
* Gets the total amount of comments for a post
* @param postId The id of the post
* @returns {Promise<number>} A promise that contains the number of comments
*/
export async function getCommentCount(postId: string): Promise<number> {
const res = await fetch(`/api/posts/${postId}/comments/count`);
const data = await res.json();
return data;
}
/**
* Gets the Engagement counts for a post by postId
* @param postId The id of the post