Vue Storefront is now Alokai! Learn More
DeleteCustomerAddress

DeleteCustomerAddress

Implements DeleteCustomerAddress Unified Method.

Source

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

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


export const deleteCustomerAddress = defineApi.deleteCustomerAddress(async (context, args) => {
  await assertAuthorized(context);
  const { id } = args;

  const response = await context.api.deleteAddress({ addressName: id });

  if (response?.success === false) {
    throw { statusCode: 400, message: response.message ?? "Error deleting address" };
  }
});