The Vue Storefront Essentials Course is now available! Learn More
GetCustomerAddresses

GetCustomerAddresses

Implements GetCustomerAddresses Unified Method.

Source

import { getCurrentCustomer, defineApi } from "@vsf-enterprise/unified-api-commercetools";
import { getNormalizers } from "@vue-storefront/unified-data-model";

export const getCustomerAddresses = defineApi.getCustomerAddresses(async (context) => {
  const customer = await getCurrentCustomer(context);
  const { normalizeCustomerAddress } = getNormalizers(context);

  return {
    addresses: customer.shippingAddresses.map((address) => normalizeCustomerAddress(address)),
  };
});