From 7e1e9a443a7e38fdbe21129c3d3c853f75bd3162 Mon Sep 17 00:00:00 2001 From: Shravya Ramesh Date: Fri, 5 Mar 2021 16:58:21 -0800 Subject: getting buttons from backend for search page --- src/services/ExploreService.ts | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'src/services') 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; +}; -- cgit v1.2.3-70-g09d2