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
@@ -3,7 +3,7 @@ import type { Favorite } from "@/lib/types"
import { httpJson } from "./http"
type Paginated<T> = {
items: T[]
items: T[] | null
meta: {
total: number
offset: number
@@ -15,7 +15,7 @@ export async function listFavorites(): Promise<Favorite[]> {
const res = await httpJson<Paginated<Favorite> | Favorite[]>("/api/v1/favorites", {
cache: "no-store",
})
return Array.isArray(res) ? res : res.items
return Array.isArray(res) ? res : (res.items ?? [])
}
export async function isFavorited(