Alokai
You are reading the documentation for v7.x and earlier, which is no longer the latest version. Switch to v8.x

updateAndGetUser

Method updating a customer profile and returning it from SAP Commerce Cloud.

This method sends a POST request to the updateAndGetUser endpoint of the Alokai Middleware which composes responses from two other endpoints: updateUser and getUser. In turn, it exchanges data with two endpoints exposed by the SAP OCC API: updateUser and getUser.

This method works only in an authenticated user session (i.e. when the vsf-sap-token cookie is present in the browser). It only updates the fields provided in the user param.

Bear in mind the SAP OCC API updateUser endpoint does not allow for updating customer uid (login) and so does not this method.

You might also want to see the updateUser method.

Signature

export declare function updateAndGetUser<Res extends User = User,
	Props extends UpdateAndGetUserProps = UpdateAndGetUserProps>(
	props: Props,
	options?: MethodOptions
): Promise<Res>;

Parameters

NameRequiredTypeDescription
propsRequiredPropsParameter object which can be used with this method. Refer to its type definition to learn about possible properties.
optionsOptionalMethodOptionsOptions 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

Updating a customer profile.

import { UpdateAndGetUserProps } from '@vsf-enterprise/sapcc-types';
import { sdk } from '~/sdk';

const props: UpdateAndGetUserProps = {
  user: {
    firstName: 'John',
    lastName: 'Doe'
  }
}

const updatedUser = await sdk.commerce.updateAndGetUser(props);

Updating a customer profile and selecting response fields.

import { UpdateAndGetUserProps } from '@vsf-enterprise/sapcc-types';
import { sdk } from '~/sdk';

const props: UpdateAndGetUserProps = {
  user: {
    firstName: 'John',
    lastName: 'Doe'
  },
  fields: 'firstName,lastName'
}

const updatedUser = await sdk.commerce.updateAndGetUser(props);

On this page