From 17fbfa29c1b78703b872221e3b590aca3ef5cf7e Mon Sep 17 00:00:00 2001 From: Husam Salhab <47015061+hsalhab@users.noreply.github.com> Date: Mon, 26 Oct 2020 18:42:02 -0400 Subject: [TMA-13] List of following (#72) * move async-storage * removed lock files * added lock files to gitignore * added the wrong file to gitignore * added following list * added numFollowers; removed redundant code * removed followercount stuff for now * Fixed follower count * Made come more changes Co-authored-by: Ashm Walia --- src/services/UserFollowServices.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/services') diff --git a/src/services/UserFollowServices.ts b/src/services/UserFollowServices.ts index bfd8058a..508c1387 100644 --- a/src/services/UserFollowServices.ts +++ b/src/services/UserFollowServices.ts @@ -5,6 +5,7 @@ import { FOLLOWERS_ENDPOINT, FOLLOW_USER_ENDPOINT, UNFOLLOW_USER_ENDPOINT, + FOLLOWING_ENDPOINT, } from '../constants'; import {ProfilePreviewType} from 'src/types'; @@ -29,6 +30,26 @@ export const loadFollowers = async (userId: string, token: string) => { return []; }; +export const loadFollowing = async (userId: string, token: string) => { + try { + const response = await fetch(FOLLOWING_ENDPOINT + `?user_id=${userId}`, { + method: 'GET', + headers: { + Authorization: 'Token ' + token, + }, + }); + if (response.status === 200) { + const body = await response.json(); + return body; + } else { + throw new Error(await response.json()); + } + } catch (error) { + console.log(error); + } + return []; +}; + export const followOrUnfollowUser = async ( follower: string, followed: string, -- cgit v1.2.3-70-g09d2