File size: 321 Bytes
e9d4f6a
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
const API_BASE = process.env.NEXT_PUBLIC_API_BASE_URL || '';

export async function fetchApi(path: string) {
  const res = await fetch(`${API_BASE}${path}`);
  if (!res.ok) {
    const text = await res.text().catch(() => 'Unknown error');
    throw new Error(`${path}: ${res.status} ${text}`);
  }
  return res.json();
}