14 lines
486 B
TypeScript
14 lines
486 B
TypeScript
|
|
/**
|
||
|
|
* Every function in src/api/ is written as if it called `API_BASE`, but
|
||
|
|
* currently resolves a local mock after a short simulated delay. Swapping
|
||
|
|
* in a real backend later means rewriting the body of these functions only
|
||
|
|
* — components and hooks never change.
|
||
|
|
*/
|
||
|
|
export const API_BASE = import.meta.env.VITE_API_URL;
|
||
|
|
|
||
|
|
export function mockFetch<T>(data: T, delayMs = 220): Promise<T> {
|
||
|
|
return new Promise((resolve) => {
|
||
|
|
setTimeout(() => resolve(data), delayMs);
|
||
|
|
});
|
||
|
|
}
|