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

getUserAddress

Method fetching a customer address from SAP Commerce Cloud.

This method sends a POST request to the getAddress endpoint of the Alokai Middleware. In turn, it exchanges data with the getAddress endpoint exposed by the SAP OCC API Address Controller.

The method fetches customer address 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.

You might also want to see the getUserAddresses method.

Signature

export declare function getUserAddress<Res extends Address = Address,
	Props extends GetAddressProps = GetAddressProps>(
	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 an Address.

Referenced Types

Examples

Fetching a customer address.

import { sdk } from '~/sdk';

const address = await sdk.commerce.getUserAddress({ addressId: '8796879552535' });

Fetching a customer address and selecting response fields.

import { sdk } from '~/sdk';

const address = await sdk.commerce.getUserAddress({
  addressId: '8796879552535',
  fields: 'firstName,lastName'
});

On this page