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
@@ -5,7 +5,7 @@ import type { Order, OrderStatus } from "@/lib/types"
import { httpJson } from "./http"
type Paginated<T> = {
items: T[]
items: T[] | null
meta: {
total: number
offset: number
@@ -59,7 +59,7 @@ export async function listOrders(options?: ListOrdersOptions): Promise<Order[]>
const res = await httpJson<Paginated<Order>>(withOffsetLimit("/api/v1/orders", options), {
cache: "no-store",
})
return res.items
return res.items ?? []
}
export async function getOrderById(orderId: string): Promise<Order | undefined> {