aboutsummaryrefslogtreecommitdiff
path: root/src/services/CommentService.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/services/CommentService.ts')
-rw-r--r--src/services/CommentService.ts18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/services/CommentService.ts b/src/services/CommentService.ts
index 3baf0305..a9a01d77 100644
--- a/src/services/CommentService.ts
+++ b/src/services/CommentService.ts
@@ -99,3 +99,21 @@ export const getCommentsCount = async (
}
return comments_count;
};
+
+export const deleteComment = async (id: string, isThread: boolean) => {
+ try {
+ const token = await AsyncStorage.getItem('token');
+ const url = isThread ? COMMENT_THREAD_ENDPOINT : COMMENTS_ENDPOINT;
+ const response = await fetch(url + `${id}/`, {
+ method: 'DELETE',
+ headers: {
+ Authorization: 'Token ' + token,
+ },
+ });
+ return response.status === 200;
+ } catch (error) {
+ console.log('Failed to delete a comment');
+ console.log(error);
+ return false;
+ }
+};