Vue Storefront is now Alokai! Learn More
GetCustomerAddresses

GetCustomerAddresses

Implements GetCustomerAddresses Unified Method.

Source

import { defineApi, getCurrentCustomer } 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)),
  };
});