Added faster polling interval (700ms) for pre-game lobby to show joining players in near real-time, while keeping slower 2.5s refresh for active games. Implemented pending request flag to prevent concurrent API calls from overlapping. Added `cache: "no-store"` to fetch configuration to ensure fresh data on every request. Updated useEffect dependency array to re-initialize polling when game start state changes.
13 lines
328 B
JavaScript
13 lines
328 B
JavaScript
import { API_BASE } from "../constants";
|
|
|
|
export async function api(path, opts = {}) {
|
|
const res = await fetch(API_BASE + path, {
|
|
credentials: "include",
|
|
cache: "no-store",
|
|
headers: { "Content-Type": "application/json" },
|
|
...opts,
|
|
});
|
|
if (!res.ok) throw new Error(await res.text());
|
|
return res.json();
|
|
}
|