diff options
| author | Ashm Walia <ashmwalia@outlook.com> | 2021-01-25 18:00:44 -0800 |
|---|---|---|
| committer | Ashm Walia <ashmwalia@outlook.com> | 2021-01-25 18:00:44 -0800 |
| commit | 755f4f540d3e759ff9ad3bc35c64b6f7fc83998b (patch) | |
| tree | 6619de58ffcd0a5c9e32a612ffc82f0d65d041d9 /src/services | |
| parent | 6cd49ed14f99fe953026e54969abc6232f3aec57 (diff) | |
Add provision to show and hide replies
Diffstat (limited to 'src/services')
| -rw-r--r-- | src/services/MomentServices.ts | 9 |
1 files changed, 5 insertions, 4 deletions
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<CommentType[]> => { + 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 ( |
