diff options
| author | Ivan Chen <ivan@tagg.id> | 2021-05-21 20:34:30 -0400 |
|---|---|---|
| committer | Ivan Chen <ivan@tagg.id> | 2021-05-21 20:34:30 -0400 |
| commit | 442f5608aeddb5c627183e150a8c79c9d5bd2a57 (patch) | |
| tree | 4346360538d0a50407ce7d76a5e8ce6b168c52aa /src/services | |
| parent | b4a4639f2ed05c02b9061d9febddf8339bc1fe26 (diff) | |
| parent | 4849c65ff2163e1a77dcb26a12ff68840df225e7 (diff) | |
Merge branch 'master' into tma853-tag-selection-screen
# Conflicts:
# src/components/common/index.ts
# src/screens/profile/CaptionScreen.tsx
Diffstat (limited to 'src/services')
| -rw-r--r-- | src/services/MomentService.ts | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/services/MomentService.ts b/src/services/MomentService.ts index 2354d18e..a26a1abb 100644 --- a/src/services/MomentService.ts +++ b/src/services/MomentService.ts @@ -1,7 +1,11 @@ import AsyncStorage from '@react-native-community/async-storage'; import RNFetchBlob from 'rn-fetch-blob'; -import {MOMENTS_ENDPOINT, MOMENT_THUMBNAIL_ENDPOINT} from '../constants'; -import {MomentType} from '../types'; +import { + MOMENTS_ENDPOINT, + MOMENT_TAGS_ENDPOINT, + MOMENT_THUMBNAIL_ENDPOINT, +} from '../constants'; +import {MomentTagType, MomentType} from '../types'; import {checkImageUploadStatus} from '../utils'; export const postMoment: ( @@ -116,3 +120,25 @@ export const loadMomentThumbnail = async (momentId: string) => { return undefined; } }; + +export const loadMomentTags = async (moment_id: string) => { + try { + const token = await AsyncStorage.getItem('token'); + const response = await fetch( + MOMENT_TAGS_ENDPOINT + `?moment_id=${moment_id}`, + { + method: 'GET', + headers: { + Authorization: 'Token ' + token, + }, + }, + ); + if (response.status === 200) { + const tags: MomentTagType[] = await response.json(); + return tags; + } + } catch (error) { + console.error(error); + return []; + } +}; |
