upgrade to node 16, add search by full product id (#84)
This commit is contained in:
@@ -84,7 +84,18 @@ async function getProductsSearchResult(
|
||||
const prods = Promise.all([
|
||||
prodApi.searchByName(q),
|
||||
prodApi.searchByArtNo(q),
|
||||
]).then((d) => d.flat());
|
||||
prodApi.searchByCompleteProductId(q),
|
||||
]).then((d) => {
|
||||
// flatten, remove falsy (each searchBy... can return undefined above)
|
||||
// and finally remove duplicates.
|
||||
const products = {} as { [key: string]: Product };
|
||||
d.flat().forEach((product) => {
|
||||
if (product && !products[product.id]) {
|
||||
products[product.id] = product;
|
||||
}
|
||||
});
|
||||
return Object.values(products);
|
||||
});
|
||||
|
||||
return {
|
||||
q: q,
|
||||
|
||||
Reference in New Issue
Block a user