fix(api): normalize empty list responses
This commit is contained in:
+2
-2
@@ -4,7 +4,7 @@ import type { Player } 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 listPlayers(): Promise<Player[]> {
|
||||
const res = await httpJson<Paginated<Player>>("/api/v1/players?offset=0&limit=100", {
|
||||
cache: "no-store",
|
||||
})
|
||||
return res.items
|
||||
return res.items ?? []
|
||||
}
|
||||
|
||||
export async function getPlayerById(playerId: string): Promise<Player | undefined> {
|
||||
|
||||
Reference in New Issue
Block a user