29 lines
726 B
JavaScript
29 lines
726 B
JavaScript
import httpClient from './httpClient';
|
|
|
|
export const postService = {
|
|
getPosts({ page = 1, limit = 10, keyword = '' } = {}) {
|
|
return httpClient.get('/posts', {
|
|
params: {
|
|
page,
|
|
limit,
|
|
keyword: keyword.trim()
|
|
}
|
|
});
|
|
},
|
|
getPost(id) {
|
|
return httpClient.get(`/posts/${id}`);
|
|
},
|
|
createPost(post) {
|
|
return httpClient.post('/posts', post);
|
|
},
|
|
|
|
updatePost(id, post) {
|
|
return httpClient.put(`/posts/${id}`, post);
|
|
},
|
|
deletePost(id) {
|
|
return httpClient.delete(`/posts/${id}`);
|
|
},
|
|
sendTo(id, userId) {
|
|
return httpClient.post(`/posts/${id}/send-to/${userId}`);
|
|
},
|
|
} |