From 0fd892ad288f2e1eaaa4fdf5e1fd6f15dbd45860 Mon Sep 17 00:00:00 2001 From: Ashm Walia <40498934+ashmgarv@users.noreply.github.com> Date: Fri, 4 Dec 2020 08:50:24 -0800 Subject: [TMA - 398 AND TMA-430] Replace Providers with Redux Store (#125) * First * WIP * Thunk * Some more comments * sc * recent searches and follounfollow * Edit profile dummy * Block / unblock and some cleanup * Replace auth provider * Sc * Delete AP after rebase * Discover users * Cleanup * More cleanup * Replace profile provider * Fixed build failure * Fixed a bug reported * Prevent app crash when backend server is down --- src/services/UserFollowServices.ts | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'src/services/UserFollowServices.ts') diff --git a/src/services/UserFollowServices.ts b/src/services/UserFollowServices.ts index 105124bc..f0f176fc 100644 --- a/src/services/UserFollowServices.ts +++ b/src/services/UserFollowServices.ts @@ -8,13 +8,7 @@ import { FOLLOWING_ENDPOINT, } from '../constants'; -import {ProfilePreviewType} from 'src/types'; - -export const loadFollowers = async ( - userId: string, - token: string, - callback: Function, -) => { +export const loadFollowers = async (userId: string, token: string) => { try { const response = await fetch(FOLLOWERS_ENDPOINT + `?user_id=${userId}`, { method: 'GET', @@ -24,7 +18,7 @@ export const loadFollowers = async ( }); if (response.status === 200) { const body = await response.json(); - callback(body); + return body; } else { throw new Error(await response.json()); } @@ -33,11 +27,7 @@ export const loadFollowers = async ( } }; -export const loadFollowing = async ( - userId: string, - token: string, - callback: Function, -) => { +export const loadFollowing = async (userId: string, token: string) => { try { const response = await fetch(FOLLOWING_ENDPOINT + `?user_id=${userId}`, { method: 'GET', @@ -47,7 +37,7 @@ export const loadFollowing = async ( }); if (response.status === 200) { const body = await response.json(); - callback(body); + return body; } else { throw new Error(await response.json()); } -- cgit v1.2.3-70-g09d2