Initial commit
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user