Vue Storefront is now Alokai! Learn More
DeleteCustomerAddress

DeleteCustomerAddress

Implements DeleteCustomerAddress Unified Method.

Source

import "./extended";
import { HttpStatusCode } from "@alokai/connect/middleware";

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

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

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

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