GetCustomer
Implements GetCustomer
Unified Method.
Source
import { defineApi, query } from "@vsf-enterprise/unified-api-magento";
import type { Customer } from "@vsf-enterprise/unified-api-magento/ecommerceTypes";
import { getNormalizers } from "@vsf-enterprise/unified-api-magento/udl";
export const getCustomer = defineApi.getCustomer(async (context) => {
const { normalizeCustomer } = getNormalizers(context);
try {
const customerData = await query(context.api.customer());
return {
customer: normalizeCustomer(customerData.customer as Customer),
};
} catch {
return { customer: null };
}
});