frontend


frontend / api/inventory/utils/fieldPickers / pickStringFromList

Function: pickStringFromList()

pickStringFromList(r, keys): undefined | string

Defined in: src/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

undefined | string

First string found, undefined if none match

Example

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