validate fetched archived games properly

This commit is contained in:
Nathaniel Tampus
2023-04-02 17:42:12 +08:00
parent ec05a7405f
commit 92dfc0c778

View File

@@ -61,12 +61,12 @@ export const getArchivedGame = async ({ id, userid }: { id?: number; userid?: nu
}); });
if (res && res.status === 200) { if (res && res.status === 200) {
if (userid) { if (id) {
const games: Game[] = await res.json();
return games;
} else {
const game: Game = await res.json(); 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) { } catch (err) {