validate fetched archived games properly
This commit is contained in:
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user