-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
87a1300
commit 1d3702c
Showing
13 changed files
with
144 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,19 @@ | ||
import { client } from '../utils/fetchClient'; | ||
import { Comment } from '../types/Comment'; | ||
|
||
const url = `/comments`; | ||
import { ENDPOINTS } from '../helpers/endPointsHelper'; | ||
|
||
export const getComments = (postId: number) => { | ||
return client.get<Comment[]>(`${url}?postId=${postId}`); | ||
return client.get<Comment[]>(`${ENDPOINTS.comments}?postId=${postId}`); | ||
}; | ||
|
||
export const createComment = (comment: Omit<Comment, 'id'>) => { | ||
return client.post<Comment>(`${url}`, comment); | ||
return client.post<Comment>(`${ENDPOINTS.comments}`, comment); | ||
}; | ||
|
||
export const editComment = (comment: Comment) => { | ||
return client.patch<Comment>(`${url}/${comment.id}`, comment); | ||
return client.patch<Comment>(`${ENDPOINTS.comments}/${comment.id}`, comment); | ||
}; | ||
|
||
export const deleteComment = (commentId: number) => { | ||
return client.delete(`${url}/${commentId}`); | ||
return client.delete(`${ENDPOINTS.comments}/${commentId}`); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,19 @@ | ||
import { client } from '../utils/fetchClient'; | ||
import { Post } from '../types/Post'; | ||
|
||
const url = `/posts`; | ||
import { ENDPOINTS } from '../helpers/endPointsHelper'; | ||
|
||
export const getPosts = (userId: number) => { | ||
return client.get<Post[]>(`${url}?userId=${userId}`); | ||
return client.get<Post[]>(`${ENDPOINTS.posts}?userId=${userId}`); | ||
}; | ||
|
||
export const createPost = (post: Omit<Post, 'id'>) => { | ||
return client.post<Post>(`${url}`, post); | ||
return client.post<Post>(`${ENDPOINTS.posts}`, post); | ||
}; | ||
|
||
export const editPost = (post: Post) => { | ||
return client.patch<Post>(`${url}/${post.id}`, post); | ||
return client.patch<Post>(`${ENDPOINTS.posts}/${post.id}`, post); | ||
}; | ||
|
||
export const deletePost = (postId: number) => { | ||
return client.delete(`${url}/${postId}`); | ||
return client.delete(`${ENDPOINTS.posts}/${postId}`); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,19 @@ | ||
import { client } from '../utils/fetchClient'; | ||
import { User } from '../types/User'; | ||
|
||
const url = `/users`; | ||
import { ENDPOINTS } from '../helpers/endPointsHelper'; | ||
|
||
export const getUsers = () => { | ||
return client.get<User[]>(`${url}`); | ||
return client.get<User[]>(`${ENDPOINTS.users}`); | ||
}; | ||
|
||
export const createUser = (user: Omit<User, 'id'>) => { | ||
return client.post<User>(`${url}`, user); | ||
return client.post<User>(`${ENDPOINTS.users}`, user); | ||
}; | ||
|
||
export const editUser = (user: User) => { | ||
return client.patch<User>(`${url}/${user.id}`, user); | ||
return client.patch<User>(`${ENDPOINTS.users}/${user.id}`, user); | ||
}; | ||
|
||
export const deleteUser = (userId: number) => { | ||
return client.delete(`${url}/${userId}`); | ||
return client.delete(`${ENDPOINTS.users}/${userId}`); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.