diff options
| author | Ivan Chen <ivan@tagg.id> | 2021-01-11 16:11:11 -0500 |
|---|---|---|
| committer | Ivan Chen <ivan@tagg.id> | 2021-01-15 14:19:50 -0500 |
| commit | 080e76350c2570eeb096fad40fe95f1b766b4539 (patch) | |
| tree | bcb9f73f2c192f8c34f2064a5c3fd003756c2823 /src/services/MomentServices.ts | |
| parent | 1dccfb1d3e9470d81de8d1ec0a0dbb3803372f7d (diff) | |
created strings.ts and linting
Diffstat (limited to 'src/services/MomentServices.ts')
| -rw-r--r-- | src/services/MomentServices.ts | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/services/MomentServices.ts b/src/services/MomentServices.ts index 91ecf712..76f353ce 100644 --- a/src/services/MomentServices.ts +++ b/src/services/MomentServices.ts @@ -1,6 +1,7 @@ import AsyncStorage from '@react-native-community/async-storage'; import {Alert} from 'react-native'; import {COMMENTS_ENDPOINT, MOMENTS_ENDPOINT} from '../constants'; +import {ERROR_FAILED_TO_COMMENT} from '../constants/strings'; import {MomentType} from '../types'; import {checkImageUploadStatus} from '../utils'; @@ -48,20 +49,12 @@ export const postMomentComment = async ( }, body: request, }); - const status = response.status; - if (status === 200) { - const response_data = await response.json(); - return response_data; - } else { - Alert.alert('Something went wrong! ðŸ˜', 'Not able to post a comment'); - return {}; + if (response.status !== 200) { + throw 'server error'; } + return await response.json(); } catch (error) { - Alert.alert( - 'Something went wrong! ðŸ˜', - 'Not able to post a comment', - error, - ); + Alert.alert(ERROR_FAILED_TO_COMMENT); return {}; } }; |
