diff options
| author | Shravya Ramesh <shravs1208@gmail.com> | 2021-03-05 16:58:21 -0800 |
|---|---|---|
| committer | Shravya Ramesh <shravs1208@gmail.com> | 2021-03-05 20:58:06 -0800 |
| commit | 7e1e9a443a7e38fdbe21129c3d3c853f75bd3162 (patch) | |
| tree | 6750c847b0335b01e88710cada5a8b411de5613f /src/services/ExploreService.ts | |
| parent | 241be3c97d5396d051071b04f53fc77e07509ae4 (diff) | |
getting buttons from backend for search page
Diffstat (limited to 'src/services/ExploreService.ts')
| -rw-r--r-- | src/services/ExploreService.ts | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/services/ExploreService.ts b/src/services/ExploreService.ts index 43c2a96a..33b79b4a 100644 --- a/src/services/ExploreService.ts +++ b/src/services/ExploreService.ts @@ -1,7 +1,15 @@ import AsyncStorage from '@react-native-community/async-storage'; -import {ALL_USERS_ENDPOINT, DISCOVER_ENDPOINT} from '../constants'; +import { + ALL_USERS_ENDPOINT, + DISCOVER_ENDPOINT, + SEARCH_BUTTONS_ENDPOPINT, +} from '../constants'; import {EMPTY_PROFILE_PREVIEW_LIST} from '../store/initialStates'; -import {ExploreSectionType, ProfilePreviewType} from '../types'; +import { + ExploreSectionType, + ProfilePreviewType, + SearchCategoryType, +} from '../types'; export const getAllTaggUsers = async (token: string) => { try { @@ -80,3 +88,20 @@ export const getDiscoverUsers = async (id: number) => { return []; } }; + +export const getButtons = async () => { + const token = await AsyncStorage.getItem('token'); + const response = await fetch(SEARCH_BUTTONS_ENDPOPINT, { + method: 'GET', + headers: { + Authorization: 'Token ' + token, + }, + }); + + if (response.status !== 200) { + return []; + } + + const data: SearchCategoryType[] = await response.json(); + return data; +}; |
