Skip to content

Commit

Permalink
Separate judge functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
dereckmezquita committed Apr 25, 2024
1 parent c73d6c2 commit 0dae740
Showing 1 changed file with 0 additions and 31 deletions.
31 changes: 0 additions & 31 deletions client/src/utils/api/interact/judge.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,5 @@
import { API_PREFIX } from "@constants/config";

const api_judge = async (type: 'article' | 'comment', id: string, judgement: string) => {
const END_POINT: string = type === 'article' ?
'/interact/judge_article' :
'/interact/judge_comment';

try {
const response = await fetch(API_PREFIX + END_POINT, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
id: id, // encodeURIComponent(id)
judgement
}),
credentials: 'include'
});

const data = await response.json();
if (!response.ok) {
throw new Error(data.message || 'Error occurred while judging.');
}

return data;
} catch (error) {
throw error;
}
}

export default api_judge;

export const api_judge_article = async (slug: string, judgement: 'like' | 'dislike') => {
try {
const response = await fetch(API_PREFIX + '/interact/judge_article', {
Expand Down

0 comments on commit 0dae740

Please sign in to comment.