diff options
| author | George Rusu <george@tagg.id> | 2021-05-25 13:35:05 -0700 | 
|---|---|---|
| committer | George Rusu <george@tagg.id> | 2021-05-25 13:35:05 -0700 | 
| commit | 4089ccdc05ffa5e02c6e0be717626cbdc631b8f2 (patch) | |
| tree | e279bfe3b33da17f85fc3ca83cbb1f338e05e4b3 /src/services/NotificationService.ts | |
| parent | a5ef509d2a1f79d85c76ee766dabe96acac2a989 (diff) | |
| parent | 7f991eef32475165f819dc8b666c5763f0021696 (diff) | |
Merge
Diffstat (limited to 'src/services/NotificationService.ts')
| -rw-r--r-- | src/services/NotificationService.ts | 51 | 
1 files changed, 25 insertions, 26 deletions
| diff --git a/src/services/NotificationService.ts b/src/services/NotificationService.ts index a62b0df9..c5c843f5 100644 --- a/src/services/NotificationService.ts +++ b/src/services/NotificationService.ts @@ -2,31 +2,30 @@ import AsyncStorage from '@react-native-community/async-storage';  import {NOTIFICATIONS_ENDPOINT} from '../constants';  import {NotificationType} from '../types'; -export const getNotificationsData: () => Promise< -  NotificationType[] -> = async () => { -  try { -    const token = await AsyncStorage.getItem('token'); -    const response = await fetch(NOTIFICATIONS_ENDPOINT, { -      method: 'GET', -      headers: { -        Authorization: 'Token ' + token, -      }, -    }); -    if (response.status === 200) { -      const data: any[] = await response.json(); -      let typedData: NotificationType[] = []; -      for (const o of data) { -        typedData.push({ -          ...o.notification, -          unread: false, -        }); +export const getNotificationsData: () => Promise<NotificationType[]> = +  async () => { +    try { +      const token = await AsyncStorage.getItem('token'); +      const response = await fetch(NOTIFICATIONS_ENDPOINT, { +        method: 'GET', +        headers: { +          Authorization: 'Token ' + token, +        }, +      }); +      if (response.status === 200) { +        const data: any[] = await response.json(); +        let typedData: NotificationType[] = []; +        for (const o of data) { +          typedData.push({ +            ...o.notification, +            unread: false, +          }); +        } +        return typedData;        } -      return typedData; +      return []; +    } catch (error) { +      console.log('Unable to fetch notifications'); +      return [];      } -    return []; -  } catch (error) { -    console.log('Unable to fetch notifications'); -    return []; -  } -}; +  }; | 
