-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathposts.ts
25 lines (24 loc) · 862 Bytes
/
posts.ts
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
import { axiosInstance } from "@/api/instance";
import { InfiniteScrollResponse, LatestPostsApiResponse, Post, UpdatePostsApiResponse } from "@/types/post";
export const posts = {
latest: async (params: { limit: number; lastId: number }): Promise<InfiniteScrollResponse<Post>> => {
const response = await axiosInstance.get<LatestPostsApiResponse>("/api/feed", {
params: {
limit: params.limit,
lastId: params.lastId || 0,
},
});
return {
result: response.data.data.result,
hasMore: response.data.data.hasMore,
lastId: response.data.data.lastId,
};
},
update: async (): Promise<UpdatePostsApiResponse> => {
const response = await axiosInstance.get<UpdatePostsApiResponse>("/api/feed/recent");
return {
message: response.data.message,
data: response.data.data,
};
},
};