aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/services/SearchService.ts9
-rw-r--r--src/utils/search.ts2
2 files changed, 7 insertions, 4 deletions
diff --git a/src/services/SearchService.ts b/src/services/SearchService.ts
index 7b97f9a7..672c1ec6 100644
--- a/src/services/SearchService.ts
+++ b/src/services/SearchService.ts
@@ -1,4 +1,5 @@
import AsyncStorage from '@react-native-community/async-storage';
+import {ProfilePreviewType} from '../types';
export const loadSearchResults = async (url: string) => {
try {
@@ -11,12 +12,14 @@ export const loadSearchResults = async (url: string) => {
});
const {status} = response;
if (status === 200) {
- const searchResults = await response.json();
+ const searchResults: {
+ users: ProfilePreviewType[];
+ } = await response.json();
return searchResults;
}
} catch (error) {
console.log(error);
- throw error;
+ return undefined;
}
- return {};
+ return undefined;
};
diff --git a/src/utils/search.ts b/src/utils/search.ts
index 789acbc3..c3246c41 100644
--- a/src/utils/search.ts
+++ b/src/utils/search.ts
@@ -147,5 +147,5 @@ export const loadTaggUserSuggestions = async (): Promise<
ProfilePreviewType[]
> => {
const searchResults = await loadSearchResults(`${SEARCH_ENDPOINT_SUGGESTED}`);
- return searchResults?.users;
+ return searchResults ? searchResults.users : [];
};