import { BASE_URL } from './api'; export const makeRequest = async ( endpoint: string, options?: RequestInit ): Promise => { const url = new URL(endpoint, BASE_URL).toString(); try { const response = await fetch(url, options); console.log(response); if (!response.ok) { let errorData; try { errorData = await response.json(); } catch (e) { // Ignore JSON parsing errors if the body is empty } const errorMessage = errorData?.message || `Request failed with status ${response.status}`; throw new Error(errorMessage); } if (response.status === 204) { return null as T; } return response.json(); } catch (error) { console.error('API request error:', error); throw error; } };