From 755f4f540d3e759ff9ad3bc35c64b6f7fc83998b Mon Sep 17 00:00:00 2001 From: Ashm Walia Date: Mon, 25 Jan 2021 18:00:44 -0800 Subject: Add provision to show and hide replies --- src/services/MomentServices.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/services') diff --git a/src/services/MomentServices.ts b/src/services/MomentServices.ts index 7bad6d4c..77740e7e 100644 --- a/src/services/MomentServices.ts +++ b/src/services/MomentServices.ts @@ -1,3 +1,4 @@ +import {CommentType} from './../types/types'; import AsyncStorage from '@react-native-community/async-storage'; import {Alert} from 'react-native'; import RNFetchBlob from 'rn-fetch-blob'; @@ -13,8 +14,8 @@ import {checkImageUploadStatus} from '../utils'; //Get all comments for a moment export const getMomentComments = async ( momentId: string, - callback: Function, -) => { +): Promise => { + let comments: CommentType[] = []; try { const token = await AsyncStorage.getItem('token'); const response = await fetch(COMMENTS_ENDPOINT + '?moment_id=' + momentId, { @@ -25,14 +26,14 @@ export const getMomentComments = async ( }); const status = response.status; if (status === 200) { - const comments = await response.json(); - callback(comments); + comments = await response.json(); } else { console.log('Could not load comments'); } } catch (error) { console.log('Could not load comments', error); } + return comments; }; export const postMomentComment = async ( -- cgit v1.2.3-70-g09d2