cambios
This commit is contained in:
1 parent
794a659369
commit
5f99b65611
349 files changed
+32252
-2180
No files matched your search
@@ -0,0 +1,13 @@
|
||||
export const API_URL = process.env.NEXT_PUBLIC_API_URL ?? "https://localhost:7030";
|
||||
|
||||
export async function apiFetch<T>(path: string): Promise<T> {
|
||||
const res = await fetch(`${API_URL}${path}`, { signal: AbortSignal.timeout(8000) });
|
||||
if (!res.ok) throw new Error(`${res.status} ${res.statusText}`);
|
||||
return res.json() as Promise<T>;
|
||||
}
|
||||
|
||||
export function assetUrl(path?: string | null): string | undefined {
|
||||
if (!path) return undefined;
|
||||
if (path.startsWith('http')) return path;
|
||||
return `${API_URL}${path}`;
|
||||
}
|
||||
Reference in new issue
Block a user