// Client for the search API type RawSearchResponse = { films: string[]; series: string[]; episodes: { series: string; title: string; path: string; season: string; }[]; }; const API_BASE_URL = 'https://hans-den-search.hf.space'; // Change this to your actual API URL export const searchAPI = { search: async (query: string): Promise => { try { const response = await fetch(`${API_BASE_URL}/api/search`, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ query }), }); if (!response.ok) { throw new Error(`Search API returned ${response.status}`); } const data = await response.json(); console.log('Search API response:', data); return data; } catch (error) { console.error('Error searching:', error); return { films: [], series: [], episodes: [] }; } }, healthCheck: async (): Promise => { try { const response = await fetch(`${API_BASE_URL}/health`); return response.ok; } catch (error) { console.error('API health check failed:', error); return false; } }, getData: async () => { try { const response = await fetch(`${API_BASE_URL}/api/data`); if (!response.ok) { throw new Error(`API returned ${response.status}`); } return await response.json(); } catch (error) { console.error('Error fetching API data:', error); return null; } } };