Vue Storefront is now Alokai! Learn More
GetCustomer

GetCustomer

Implements GetCustomer Unified Method.

Source

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


declare module "@vsf-enterprise/unified-api-sfcc" {
  interface GetCustomerExtendedArgs {}
}


export const getCustomer = defineApi.getCustomer(async (context) => {
  const { normalizeCustomer } = getNormalizers(context);

  try {
    const customerData = await context.api.getCustomer();
    return { customer: normalizeCustomer(customerData) };
  } catch {
    return { customer: null };
  }
});