First commit: ready to implement features
This commit is contained in:
+16
@@ -0,0 +1,16 @@
|
||||
const API_BASE = import.meta.env.VITE_API_BASE;
|
||||
const API_KEY = import.meta.env.VITE_API_KEY;
|
||||
|
||||
export async function apiGet<T>(path: string): Promise<T> {
|
||||
const response = await fetch(`${API_BASE}${path}`, {
|
||||
headers: {
|
||||
"X-API-Key": API_KEY,
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`API error ${response.status}`);
|
||||
}
|
||||
|
||||
return response.json();
|
||||
}
|
||||
Reference in New Issue
Block a user