Vue Storefront is now Alokai! Learn More
GetCustomerAddresses

GetCustomerAddresses

Implements GetCustomerAddresses Unified Method.

Source

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

export const getCustomerAddresses = defineApi.getCustomerAddresses(async (context) => {
  const { addresses = [] } = await getCurrentCustomer(context);

  const { normalizeCustomerAddress } = getNormalizers(context);

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