From 629fccf484d14717f5e1408f486e0fbfac343089 Mon Sep 17 00:00:00 2001 From: GuillaumeSD Date: Sun, 1 Jun 2025 04:04:21 +0200 Subject: [PATCH] fix : date cannot be set in the future error --- src/lib/chessCom.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/lib/chessCom.ts b/src/lib/chessCom.ts index 08b1124..79035cc 100644 --- a/src/lib/chessCom.ts +++ b/src/lib/chessCom.ts @@ -15,12 +15,15 @@ export const getChessComUserRecentGames = async ( { method: "GET", signal } ); - if (res.status >= 400) { + const data = await res.json(); + + if ( + res.status >= 400 && + data.message !== "Date cannot be set in the future" + ) { throw new Error("Error fetching games from Chess.com"); } - const data = await res.json(); - const games: ChessComGame[] = data?.games ?? []; if (games.length < 50) {