frontend / api/inventory/utils/responseExtraction / extractArray
Function: extractArray()
extractArray(
obj,keys):unknown[]
Defined in: src/api/inventory/utils/responseExtraction.ts:52
From an unknown response object, try to pull an array from one of the keys. Useful for extracting arrays from envelope formats like { items: [...] } or { content: [...] }. Falls back to [] if nothing sane is found.
Parameters
obj
unknown
Response object to extract array from
keys
string[]
Keys to try in order (e.g., ['items', 'content', 'data'])
Returns
unknown[]
Array if found in one of the keys, empty array otherwise
Example
const items = extractArray(response, ['items', 'content']);