UNPKG

@fakel/rest-admin

Version:

An application that makes it easier to work with your API

20 lines (18 loc) 418 B
import get from 'lodash.get'; import { v4 as uuid } from 'uuid'; import { OptionT } from '../@types'; export const mapRecordsToOptions = ( records: any, source: string, titlePropName: string, ): OptionT[] => { return records.map((record, index) => { const value = get(record, source); const title = get(record, titlePropName); return { key: uuid(), value, title, }; }); };