From 2fa9e06af6b4f5f57a1106cab1ad11984d0d5783 Mon Sep 17 00:00:00 2001 From: OkMoroz Date: Mon, 23 Dec 2024 14:26:11 +0200 Subject: [PATCH] fixed after mentors review --- src/api/comments.ts | 7 ++++--- src/constans/comments.tsx | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 src/constans/comments.tsx diff --git a/src/api/comments.ts b/src/api/comments.ts index 03b447eb6..d91eef394 100644 --- a/src/api/comments.ts +++ b/src/api/comments.ts @@ -1,14 +1,15 @@ import { Comment, CommentData } from '../types/Comment'; import { client } from '../utils/fetchClient'; +import { COMMENTS } from '../constans/comments'; export const getComments = (postId: number) => { - return client.get(`/comments?postId=${postId}`); + return client.get(`${COMMENTS}?postId=${postId}`); }; export const deleteComment = (commentId: number) => { - return client.delete(`/comments/${commentId}`); + return client.delete(`${COMMENTS}${commentId}`); }; export const addComment = (newComment: CommentData) => { - return client.post('/comments', newComment); + return client.post(`${COMMENTS}`, newComment); }; diff --git a/src/constans/comments.tsx b/src/constans/comments.tsx new file mode 100644 index 000000000..d5771e3a9 --- /dev/null +++ b/src/constans/comments.tsx @@ -0,0 +1 @@ +export const COMMENTS = '/comments';