UNPKG

@ecomplus/utils

Version:

JS utility functions to E-Com Plus (not only) related apps

25 lines 1.06 kB
export default searchedItems; /** * @method * @memberof ecomUtils * @name searchedItems * @description Returns array of items (products) from Search API response. * @param {Object.<string, *>|Array} result - Search response body or ELS hits array * @returns {Array} * * @example * // Full Search API response samples: * // https://developers.e-com.plus/docs/api/#/search/items/items * const result = { took: 6, hits: { total: 2, hits: [] } } * result.hits.hits.push({ _id: '123', _source: { sku: 'TEST', name: 'Test' } }) * result.hits.hits.push({ _id: '456', _source: { sku: 'SMP', name: 'Smp' } }) * ecomUtils.searchedItems(result) * // => [ { _id: '123', sku: 'TEST', name: 'Test' }, { _id: '456', sku: 'SMP', name: 'Smp' } ] * // Same passing the `hits` array as param * ecomUtils.searchedItems(result.hits.hits) * // => [ { _id: '123', sku: 'TEST', name: 'Test' }, { _id: '456', sku: 'SMP', name: 'Smp' } ] */ declare function searchedItems(result: { [x: string]: any; } | any[]): any[]; //# sourceMappingURL=searched-items.d.ts.map