Vue Storefront is now Alokai! Learn More
GetCustomer

GetCustomer

Implements GetCustomer Unified Method.

Source

import { getNormalizers } from "@alokai/connect/integration-kit";

import { defineApi } from "@vsf-enterprise/unified-api-bigcommerce";

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

  try {
    const { api } = await context.getApiClient();
    const {
      data: { 0: user },
    } = await api.getCustomers({});

    return {
      customer: normalizeCustomer(user!),
    };
  } catch {
    return {
      customer: null,
    };
  }
});