const BASE_URL = import.meta.env.VITE_API_URL

async function apiRequest(endpoint, options = {}) {
    const response = await fetch(`${BASE_URL}${endpoint}`, {
        headers: {
            "Content-Type": "application/json",
            ...(options.headers || {})
        },
        ...options
    });

    if (!response.ok) {
        const error = await response.json();
        throw error;
    }

    return response.json();
}

window.apiRequest = apiRequest;
