fix(api): normalize empty list responses
This commit is contained in:
+2
-1
@@ -24,7 +24,7 @@ export type ListDisputesOptions = {
|
||||
}
|
||||
|
||||
type Paginated<T> = {
|
||||
items: T[]
|
||||
items: T[] | null
|
||||
meta?: {
|
||||
total: number
|
||||
offset: number
|
||||
@@ -50,6 +50,7 @@ function unwrapItems<T>(value: unknown): T[] {
|
||||
if ("items" in value) {
|
||||
const envelope = value as { items?: unknown }
|
||||
if (Array.isArray(envelope.items)) return envelope.items as T[]
|
||||
if (envelope.items === null) return []
|
||||
}
|
||||
throw new Error("Invalid response")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user