modified: files to ios26 ui/ux
This commit is contained in:
@@ -7,22 +7,27 @@ export type SearchResultItem = {
|
||||
|
||||
const DISCOVER_BASE = "https://fltr-app.de/api/discover/search";
|
||||
|
||||
export async function getSearchResults(
|
||||
tags: string[] | string,
|
||||
limit = 10,
|
||||
signal?: AbortSignal
|
||||
export async function discoverSearch(
|
||||
tags: string[],
|
||||
signal?: AbortSignal,
|
||||
): Promise<SearchResultItem[]> {
|
||||
const tagList = Array.isArray(tags) ? tags : [tags];
|
||||
const filteredTags = tagList.map((t) => t.trim()).filter(Boolean);
|
||||
const filteredTags = tags.map((t) => t.trim()).filter(Boolean);
|
||||
if (!filteredTags.length) return [];
|
||||
|
||||
const url = `${DISCOVER_BASE}?tags=${encodeURIComponent(
|
||||
filteredTags.join(",")
|
||||
)}&limit=${limit}`;
|
||||
const params = filteredTags
|
||||
.map((tag) => `tags=${encodeURIComponent(tag)}`)
|
||||
.join("&");
|
||||
const url = `${DISCOVER_BASE}?${params}`;
|
||||
|
||||
const apiKey = process.env.EXPO_PUBLIC_API_KEY;
|
||||
const res = await fetch(url, { signal, headers: { 'Content-Type': 'application/json', "X-API-Key": apiKey ?? "", } });
|
||||
if (!res.ok) throw new Error("AutoComplete failed " + res.status);
|
||||
const res = await fetch(url, {
|
||||
signal,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-Key": apiKey ?? "",
|
||||
},
|
||||
});
|
||||
if (!res.ok) throw new Error("Discover search failed " + res.status);
|
||||
|
||||
const data: unknown = await res.json();
|
||||
if (!Array.isArray(data)) return [];
|
||||
|
||||
Reference in New Issue
Block a user