api: reconfigered api handling
This commit is contained in:
@@ -16,7 +16,8 @@ export async function getAutoComplete(
|
||||
const url = `${DISCOVER_BASE}/autoComplete?q=${encodeURIComponent(
|
||||
query
|
||||
)}&limit=${limit}`;
|
||||
const res = await fetch(url, { signal });
|
||||
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 data: unknown = await res.json();
|
||||
if (!Array.isArray(data)) return [];
|
||||
|
||||
Reference in New Issue
Block a user