diff --git a/lib/delivery-locations-resolver.js b/lib/delivery-locations-resolver.js index 78ee2bf4..86ac983d 100644 --- a/lib/delivery-locations-resolver.js +++ b/lib/delivery-locations-resolver.js @@ -138,10 +138,11 @@ class DeliveryLocationsResolver { const ellapsed = ((new Date()) - __startAll) logger.debug({ message: `HTC searchByParam API across ${barcodes.length} barcodes took ${ellapsed}ms total`, metric: 'searchByParam-barcode-multiple', timeMs: ellapsed }) - // Filter out anything `undefined` and make sure at least one is valid: - const validPairs = [{}].concat(scsbResponses.filter((r) => r)) - // Merge array of hashes into one big lookup hash: - return Object.assign.apply(null, validPairs) + // Build barcode-customerCode map: + return barcodes.reduce((h, barcode, ind) => { + if (scsbResponses[ind]) h[barcode] = scsbResponses[ind] + return h + }, {}) }) }