const API_BASE = "";

async function apiGet(path, params = {}) {
  const query = new URLSearchParams(params).toString();
  const url = `${API_BASE}${path}?${query}`;

  console.log(`📡 API GET: ${url}`);

  const res = await fetch(url);

  console.log(`📊 Response status: ${res.status}`);

  if (!res.ok) {
    const data = await res.json();
    console.error(`❌ API Error:`, data);
    throw new Error(data.detail || "APIエラー");
  }

  const jsonData = await res.json();
  console.log(`✅ API Response:`, jsonData);

  return jsonData;
}
