-
Notifications
You must be signed in to change notification settings - Fork 34
/
feed.tsx
40 lines (36 loc) · 965 Bytes
/
feed.tsx
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
import { Kitsu } from 'kitsu/config/api';
/**
* Fetches post by the given id.
* @param {any} postId The id of the post
* @returns {object} post
*/
export const fetchPost = async (postId) => {
if (!postId) return null;
try {
const post = await Kitsu.find('posts', postId, {
include: 'user,targetUser,targetGroup,media,uploads,spoiledUnit',
});
return post;
} catch (e) {
console.log(e);
}
return null;
};
/**
* Fetches comment by the given id.
* @param {any} commentId The id of the comment
* @returns {object} comment
*/
export const fetchComment = async (commentId) => {
if (!commentId) return null;
try {
const comment = await Kitsu.find('comments', commentId, {
include:
'user,uploads,parent,parent.user,parent.uploads,post,post.user,post.targetUser,post.targetGroup,post.media,post.uploads,post.spoiledUnit',
});
return comment;
} catch (e) {
console.log(e);
}
return null;
};