Vue Storefront is now Alokai! Learn More
GetCustomerAddresses

GetCustomerAddresses

Implements GetCustomerAddresses Unified Method.

Source

import { assertAuthorized, defineApi } from "@vsf-enterprise/unified-api-bigcommerce";
import { getNormalizers } from "@vsf-enterprise/unified-api-bigcommerce/udl";

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)),
  };
});