File size: 708 Bytes
f5071ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
 export const fetchComments = postId => (
  $.ajax({
    url: `/api/posts/${postId}/comments`,
  })
);

export const fetchComment = (postId, commentId) => (
  $.ajax({
    url: `/api/posts/${postId}/comments/${commentId}`,
  })
);

export const postComment = (postId, comment) => (
  $.ajax({
    url: `/api/posts/${postId}/comments`,
    method: "POST",
    data: { comment },
  })
);

export const patchComment = (postId, comment) => (
  $.ajax({
    url: `/api/posts/${postId}/comments/${comment.id}`,
    method: "PATCH",
    data: { comment },
  })
);

export const deleteComment = (postId, commentId) => (
  $.ajax({
    url: `/api/posts/${postId}/comments/${commentId}`,
    method: "DELETE",
  })
);