Skip to content

Commit

Permalink
Merge pull request #11 from lukso-network/fix/empty-response
Browse files Browse the repository at this point in the history
Add empty response handling when UP is disabled
  • Loading branch information
Wolmin authored Dec 7, 2023
2 parents 586da81 + 76e1813 commit 5058f32
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/api/useUniversalProfileApiFetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { UniversalProfileProxyResponse } from '../../types/api/universalPro
import type { Params as FetchParams } from 'lib/hooks/useFetch';

import { algoliaIndex } from './buildUniversalProfileUrl';
import { isUniversalProfileEnabled } from './isUniversalProfileEnabled';
import type { ResourceName, ResourcePathParams } from './resources';

export interface Params<R extends ResourceName> {
Expand All @@ -17,6 +18,9 @@ export interface Params<R extends ResourceName> {
export default function useUniversalProfileApiFetch() {
return React.useCallback(async(queryParams: string,
) => {
if (!isUniversalProfileEnabled()) {
return [] as Array<SearchResultAddressOrContractOrUniversalProfile>;
}
try {
const { hits } = await algoliaIndex.search(queryParams);
return hits.map<SearchResultAddressOrContractOrUniversalProfile>((hit) => {
Expand Down

0 comments on commit 5058f32

Please sign in to comment.