Handlers for GET and POST engages added, renders numbers of unique engagements per post

This commit is contained in:
Hollgy 2024-03-22 22:38:18 +01:00
parent efcdaf0cd2
commit ea25fa9489
4 changed files with 75 additions and 27 deletions

View file

@ -90,9 +90,13 @@ export async function getComments(
return data;
}
/** Incomplete */
export async function engagePost(postId: string): Promise<void> {
const res = await fetch(`/api/engage_post?post_id=${postId}`);
/**
* Gets the Engagement counts for a post by postId
* @param postId The id of the post
* @returns {Promise<number>} A promise that contains number of post engages
*/
export async function getEngagementCount(postId: string): Promise<number> {
const res = await fetch(`/api/posts/${postId}/engage`);
const data = await res.json();
return data;
}