diff options
| author | Ivan Chen <ivan@tagg.id> | 2021-06-11 18:12:24 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-11 18:12:24 -0400 |
| commit | 78f32c1400eff46d4c768b78fbaf672826c74285 (patch) | |
| tree | 00e62c1821d4973d214fdd47f8293749972c1925 /src/services | |
| parent | 4add0eed33032012fb945fb02a928aed426b9465 (diff) | |
| parent | 24f79b9cb3456b3901155ed2e4c8fc66710b97b2 (diff) | |
Merge pull request #466 from IvanIFChen/tma904-moment-comment-revamp
[TMA-904] Moment Comment Revamp
Diffstat (limited to 'src/services')
| -rw-r--r-- | src/services/MomentService.ts | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/src/services/MomentService.ts b/src/services/MomentService.ts index c66d2786..b837585a 100644 --- a/src/services/MomentService.ts +++ b/src/services/MomentService.ts @@ -6,7 +6,7 @@ import { MOMENT_TAGS_ENDPOINT, MOMENT_THUMBNAIL_ENDPOINT, } from '../constants'; -import {MomentTagType, MomentType} from '../types'; +import {MomentPostType, MomentTagType} from '../types'; import {checkImageUploadStatus} from '../utils'; export const postMoment = async ( @@ -86,11 +86,7 @@ export const patchMoment = async ( return false; }; -export const loadMoments: ( - userId: string, - token: string, -) => Promise<MomentType[]> = async (userId, token) => { - let moments: MomentType[] = []; +export const loadMoments = async (userId: string, token: string) => { try { const response = await fetch(MOMENTS_ENDPOINT + '?user_id=' + userId, { method: 'GET', @@ -98,19 +94,14 @@ export const loadMoments: ( Authorization: 'Token ' + token, }, }); - const status = response.status; - if (status === 200) { - const data = await response.json(); - moments = data; - } else { - console.log('Could not load moments!'); - return []; + if (response.status === 200) { + const typedData: MomentPostType[] = await response.json(); + return typedData; } } catch (err) { console.log(err); - return []; } - return moments; + return []; }; export const deleteMoment = async (momentId: string) => { |
