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

GetCustomerAddresses

Implements GetCustomerAddresses Unified Method.

Source

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

export const getCustomerAddresses = defineApi.getCustomerAddresses(async (context) => {
  await assertAuthorized(context);
  const addresses = await context.api.getCustomerAddress({});
  const { normalizeCustomerAddress } = getNormalizers(context);

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