Vue Storefront is now Alokai! Learn More
GetProducts

GetProducts

Implements GetProducts Unified Method.

Source

import { defineApi } from "@vsf-enterprise/unified-api-commercetools";
import { getNormalizers } from "@vsf-enterprise/unified-api-commercetools/udl";

export const getProducts = defineApi.getProducts(async (context, args) => {
  const { ids, skus } = args;
  const { normalizeProductCatalogItem } = getNormalizers(context);

  const responseData = await context.api.getProduct({ ids, skus });
  const { results = [] } = responseData.products || {};

  const products = results.map((product) => normalizeProductCatalogItem(product));

  return {
    products,
  };
});