From 92dfc0c7782d255bbc16d9c4f191f38467ad9e41 Mon Sep 17 00:00:00 2001 From: Nathaniel Tampus Date: Sun, 2 Apr 2023 17:42:12 +0800 Subject: [PATCH] validate fetched archived games properly --- client/src/lib/game.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/client/src/lib/game.ts b/client/src/lib/game.ts index ba9dc0f..c5dcd46 100644 --- a/client/src/lib/game.ts +++ b/client/src/lib/game.ts @@ -61,12 +61,12 @@ export const getArchivedGame = async ({ id, userid }: { id?: number; userid?: nu }); if (res && res.status === 200) { - if (userid) { - const games: Game[] = await res.json(); - return games; - } else { + if (id) { const game: Game = await res.json(); - return game; + if (game.id) return game; + } else { + const games: Game[] = await res.json(); + if (games.length && games[0].id) return games; } } } catch (err) {