Vue Storefront is now Alokai! Learn More
LogoutCustomer

LogoutCustomer

Implements LogoutCustomer Unified Method.

Source

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

export const logoutCustomer = defineApi.logoutCustomer(async (context) => {
  try {
    await context.api.revokeCustomerToken();
    context.res.clearCookie(context.config.cookies.customerCookieName);
    context.config.state.setCustomerToken(null);
    context.config.state.setCartId(null);
    // eslint-disable-next-line no-empty
  } catch {}
});