fix(api): normalize empty list responses

This commit is contained in:
zetaloop
2026-04-26 01:53:05 +08:00
parent 904148bd55
commit 30c336345e
11 changed files with 28 additions and 23 deletions
+2 -2
View File
@@ -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> {