You are reading the documentation for v7.x and earlier, which is no longer the latest version. Switch to v8.x
createUser
Method registering a new user in SAP Commerce Cloud.
This method sends a POST request to the createUser endpoint of the Alokai Middleware. In turn, it exchanges data with the createUser endpoint exposed by the SAP OCC API Users Controller.
This method works only in an anonymous user session (i.e. when the vsf-sap-token cookie is not present in the browser).
Signature
export declare function createUser<Res extends User = User,
Props extends UserSignUpProps = UserSignUpProps>(
props: Props,
options?: MethodOptions
): Promise<Res>;Parameters
| Name | Required | Type | Description |
|---|---|---|---|
props | Required | 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
Creating a new user.
import { UserSignUpProps } from '@vsf-enterprise/sapcc-types';
import { sdk } from '~/sdk';
const props: UserSignUpProps = {
titleCode: 'mr',
firstName: 'John',
lastName: 'Doe',
password: 'Test1234!',
uid: 'test@gmail.com'
}
const user = await sdk.commerce.createUser(props);Creating a new user and selecting response fields.
import { UserSignUpProps } from '@vsf-enterprise/sapcc-types';
import { sdk } from '~/sdk';
const props: UserSignUpProps = {
titleCode: 'mr',
firstName: 'John',
lastName: 'Doe',
password: 'Test1234!',
uid: 'test@gmail.com',
fields: 'uid,firstName'
}
const user = await sdk.commerce.createUser(props);