You are reading the documentation for v7.x and earlier, which is no longer the latest version. Switch to v8.x
getUser
Method fetching a customer profile from SAP Commerce Cloud.
This method sends a POST request to the getUser endpoint of the Alokai Middleware. In turn, it exchanges data with the getUser endpoint exposed by the SAP OCC API Users Controller.
The method fetches a customer profile based on the vsf-sap-token cookie (which is assigned to that customer). The cookie must be present in the browser for the method to work properly.
Signature
export declare function getUser<Res extends User = User,
Props extends BaseProps & BaseUserId = BaseProps & BaseUserId>(
props?: Props,
options?: MethodOptions
): Promise<Res>;Parameters
| Name | Required | Type | Description |
|---|---|---|---|
props | Optional | Props | Parameter object which can be used with this method. Refer to its type definition to learn about possible properties. |
options | Optional | MethodOptions | Options that can be passed to additionally configure the request or customize the logic in a plugin. |
Returns
Returns a representation of a User.
Referenced Types
Examples
Fetching a customer profile.
import { sdk } from '~/sdk';
const user = await sdk.commerce.getUser();Fetching a customer profile and selecting response fields.
import { sdk } from '~/sdk';
const user = await sdk.commerce.getUser({ fields: 'uid,firstName' });