aboutsummaryrefslogtreecommitdiff
path: root/src/services/SearchService.ts
blob: 7b97f9a7d7bd0e2d276b100d676fd0a05dbd495a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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 {};
};