Alokai
You are reading the documentation for SDK v2, which is no longer the latest version. Switch to current

getIdentity

Method that checks if current user is logged in or a non-logged in guest.

This method sends a POST request to the getMe endpoint of the Vue Storefront API Middleware. In turn, it fetches the customer profile for commercetools by sending a request to its GraphQL API.

Signature

export declare function getIdentity(
	options?: MethodBaseOptions
): Promise<GetIdentityResponse>;

Parameters

NameRequiredTypeDescription
optionsOptionalMethodBaseOptionsOptions that can be passed to additionally configure the request or customize the logic in a plugin.

Returns

Returns a representation of the GetIdentityResponse.

Referenced Types

Examples

Getting the identity of the request sender.

import { sdk } from '~/sdk.config.ts';

const { identity, data } = await sdk.commerce.getIdentity();

On this page