fix(api): normalize empty list responses
This commit is contained in:
+2
-2
@@ -4,7 +4,7 @@ import type { Game } from "@/lib/types"
|
||||
import { httpJson } from "./http"
|
||||
|
||||
type Paginated<T> = {
|
||||
items: T[]
|
||||
items: T[] | null
|
||||
meta: {
|
||||
total: number
|
||||
offset: number
|
||||
@@ -16,7 +16,7 @@ export async function listGames(): Promise<Game[]> {
|
||||
const res = await httpJson<Paginated<Game>>("/api/v1/games?offset=0&limit=100", {
|
||||
cache: "no-store",
|
||||
})
|
||||
return res.items
|
||||
return res.items ?? []
|
||||
}
|
||||
|
||||
export async function getGameById(gameId: string): Promise<Game | undefined> {
|
||||
|
||||
Reference in New Issue
Block a user