fix : loading game from CC and lichess

This commit is contained in:
GuillaumeSD
2025-05-12 14:11:24 +02:00
parent 046d53e7dc
commit 2b79434d45
4 changed files with 44 additions and 25 deletions

View File

@@ -56,14 +56,17 @@ export const getLichessEval = async (
};
export const getLichessUserRecentGames = async (
username: string
username: string,
signal?: AbortSignal
): Promise<LichessGame[]> => {
const res = await fetch(
`https://lichess.org/api/games/user/${username}?until=${Date.now()}&max=50&pgnInJson=true&sort=dateDesc&clocks=true`,
{ method: "GET", headers: { accept: "application/x-ndjson" } }
{ method: "GET", headers: { accept: "application/x-ndjson" }, signal }
);
if (res.status === 404) return [];
if (res.status >= 400) {
throw new Error("Error fetching games from Lichess");
}
const rawData = await res.text();
const games: LichessGame[] = rawData