Vue Storefront is now Alokai! Learn More
GetOrderDetails

GetOrderDetails

Implements GetOrderDetails Unified Method.

Source

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

export const getOrderDetails = defineApi.getOrderDetails(async (context, args) => {
  await getCurrentCustomer(context);
  const { id } = args;
  const { normalizeOrder } = getNormalizers(context);

  const {
    orders: { 0: order },
  } = await getOrderQuery(context, { id });

  return normalizeOrder(order!);
});