Vue Storefront is now Alokai! Learn More
GetCustomerAddresses

GetCustomerAddresses

Implements GetCustomerAddresses Unified Method.

Source

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

export const getCustomerAddresses = defineApi.getCustomerAddresses(async (context) => {
  assertAuthorized(context);

  const { normalizeCustomerAddress } = getNormalizers(context);
  const { addresses = [] } = await context.api.getAddresses({});

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