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 "@vue-storefront/unified-data-model";
import "./extended.d";

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