Files
Salon/frontend/src/api/client.js
T
2026-02-27 15:01:06 +03:00

15 lines
401 B
JavaScript

const API_BASE = import.meta.env.VITE_API_BASE || "/api";
async function handleResponse(response) {
if (!response.ok) {
const errorText = await response.text();
throw new Error(errorText || `Request failed: ${response.status}`);
}
return response.json();
}
export async function apiGet(path) {
const response = await fetch(`${API_BASE}${path}`);
return handleResponse(response);
}