diff options
author | ankit-thanekar007 <ankit.thanekar007@gmail.com> | 2021-03-04 16:06:21 -0800 |
---|---|---|
committer | ankit-thanekar007 <ankit.thanekar007@gmail.com> | 2021-03-04 16:06:21 -0800 |
commit | 79396f899fe25f611d790d918e8ae4275a61e43c (patch) | |
tree | f5c9c003091d3d28ca32b31bb2b1bf8f67892acc /src/services/SearchService.ts | |
parent | 95bc850b9db986b9f462f19d7801218027307d58 (diff) |
TMA-663-Changes for empty view
Diffstat (limited to 'src/services/SearchService.ts')
-rw-r--r-- | src/services/SearchService.ts | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/services/SearchService.ts b/src/services/SearchService.ts new file mode 100644 index 00000000..7b97f9a7 --- /dev/null +++ b/src/services/SearchService.ts @@ -0,0 +1,22 @@ +import AsyncStorage from '@react-native-community/async-storage'; + +export const loadSearchResults = async (url: string) => { + try { + const token = await AsyncStorage.getItem('token'); + const response = await fetch(url, { + method: 'GET', + headers: { + Authorization: 'Token ' + token, + }, + }); + const {status} = response; + if (status === 200) { + const searchResults = await response.json(); + return searchResults; + } + } catch (error) { + console.log(error); + throw error; + } + return {}; +}; |