diff options
Diffstat (limited to 'src/services/UserProfileService.ts')
-rw-r--r-- | src/services/UserProfileService.ts | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/services/UserProfileService.ts b/src/services/UserProfileService.ts index 31383f67..a2d53dbb 100644 --- a/src/services/UserProfileService.ts +++ b/src/services/UserProfileService.ts @@ -3,7 +3,7 @@ import AsyncStorage from '@react-native-community/async-storage'; import {Alert} from 'react-native'; import RNFetchBlob from 'rn-fetch-blob'; -import {SocialAccountType} from 'src/types'; +import {SocialAccountType, MomentType} from 'src/types'; import { AVATAR_PHOTO_ENDPOINT, COVER_PHOTO_ENDPOINT, @@ -11,6 +11,7 @@ import { GET_IG_POSTS_ENDPOINT, GET_TWITTER_POSTS_ENDPOINT, PROFILE_INFO_ENDPOINT, + MOMENTS_ENDPOINT, } from '../constants'; export const loadProfileInfo = async ( @@ -119,6 +120,33 @@ export const loadSocialPosts: ( return accountData; }; +export const loadMoments: ( + userId: string, + token: string, +) => Promise<MomentType[]> = async (userId, token) => { + let moments: MomentType[] = []; + try { + const response = await fetch(MOMENTS_ENDPOINT + '?user_id=' + userId, { + method: 'GET', + headers: { + 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 []; + } + } catch (err) { + console.log(err); + return []; + } + return moments; +}; + export const loadRecentlySearchedUsers = async (callback: Function) => { try { const asyncCache = await AsyncStorage.getItem('@recently_searched_users'); |