diff options
| author | Ivan Chen <ivan@thetaggid.com> | 2020-12-07 19:19:50 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-07 19:19:50 -0500 |
| commit | 84616a6143fea58899eafa915a73592eaad25361 (patch) | |
| tree | f99a662a1661348faa8d9836fb5a97ff687addf0 /src/services | |
| parent | a6dd130d5b89650e1ff134595c071f7f9c6be114 (diff) | |
[TMA-409] Delete Moments (#124)
* edit profile to use HeaderHeight instead of percentage
* delete moment done with TODOs for backend
* actually hitting the endpoint
* ops
* moved isProfileView check to drawer component
* misunderstood suggestion, now is better
* an extra layer of indirection
* fixed some bugs and code improvement
Diffstat (limited to 'src/services')
| -rw-r--r-- | src/services/MomentServices.ts | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/services/MomentServices.ts b/src/services/MomentServices.ts index 46ca1351..ed868582 100644 --- a/src/services/MomentServices.ts +++ b/src/services/MomentServices.ts @@ -1,6 +1,6 @@ -//Common moments api abstracted out here -import {COMMENTS_ENDPOINT, MOMENTS_ENDPOINT} from '../constants'; +import AsyncStorage from '@react-native-community/async-storage'; import {Alert} from 'react-native'; +import {COMMENTS_ENDPOINT, MOMENTS_ENDPOINT} from '../constants'; import {MomentType} from '../types'; //Get all comments for a moment @@ -123,3 +123,21 @@ export const loadMoments: ( } return moments; }; + +export const deleteMoment = async (momentId: string) => { + try { + const token = await AsyncStorage.getItem('token'); + + const response = await fetch(MOMENTS_ENDPOINT + `${momentId}/`, { + method: 'DELETE', + headers: { + Authorization: 'Token ' + token, + }, + }); + return response.status === 200; + } catch (error) { + console.log(error); + console.log('Unable to delete moment', momentId); + return false; + } +}; |
