aboutsummaryrefslogtreecommitdiff
path: root/src/services
diff options
context:
space:
mode:
Diffstat (limited to 'src/services')
-rw-r--r--src/services/MomentServices.ts9
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 (