frontend


frontend / api/inventory/utils/fieldPickers / pickStringFromList

Function: pickStringFromList()

pickStringFromList(r, keys): string | undefined

Defined in: api/inventory/utils/fieldPickers.ts:95

Try a list of keys and return the first string value found. Useful for handling multiple possible field names from backend.

Parameters

r

Record<string, unknown>

Record to extract from

keys

string[]

Keys to try in order

Returns

string | undefined

First string found, undefined if none match

Example

const name = pickStringFromList(obj, ['name', 'itemName', 'title']);