-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaxios.ts
More file actions
73 lines (62 loc) · 2 KB
/
axios.ts
File metadata and controls
73 lines (62 loc) · 2 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import apiRequest from '@shared/apis/setting/axiosInstance';
import { EditArticleRequest } from '@shared/types/api';
import { formatLocalDateTime } from '@shared/utils/formatDateTime';
export const getDashboardCategories = async () => {
const { data } = await apiRequest.get('/api/v1/categories/dashboard');
return data.data;
};
export const postCategory = async (categoryName: string) => {
const response = await apiRequest.post('/api/v1/categories', {
categoryName,
});
return response;
};
export const putCategory = async (id: number, categoryName: string) => {
const response = await apiRequest.put(`/api/v1/categories/${id}`, {
categoryName,
});
return response;
};
export const getAcorns = async () => {
const now = formatLocalDateTime(new Date());
const { data } = await apiRequest.get('/api/v1/users/acorns?', {
params: { now },
});
return data.data;
};
export interface postSignUpRequest {
email: string;
remindDefault: string;
fcmToken: string | null;
}
export const postSignUp = async (responsedata: postSignUpRequest) => {
const { data } = await apiRequest.post('/api/v1/auth/signup', responsedata);
return data;
};
export const putArticleReadStatus = async (articleId: number) => {
const { data } = await apiRequest.put(
`/api/v1/articles/${articleId}/readStatus`
);
return data;
};
export const getArticleDetail = async (articleId: number) => {
const { data } = await apiRequest.get(`/api/v1/articles/${articleId}`);
return data.data;
};
export const putEditArticle = async (
articleId: number,
editArticleData: EditArticleRequest
) => {
const response = await apiRequest.put(`/api/v1/articles/${articleId}`, {
...editArticleData,
});
return response;
};
export const deleteCategory = async (id: number) => {
const response = await apiRequest.delete(`/api/v1/categories/${id}`);
return response;
};
export const deleteRemindArticle = async (id: number) => {
const response = await apiRequest.delete(`/api/v1/articles/${id}`);
return response;
};