You are reading the documentation for v7.x and earlier, which is no longer the latest version. Switch to v8.x
getUserAddresses
Method fetching customers addresses from SAP Commerce Cloud.
This method sends a POST request to the getAddresses endpoint of the Alokai Middleware. In turn, it exchanges data with the getAddresses endpoint exposed by the SAP OCC API Address Controller.
The method fetches customer addresses 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 getUserAddress method.
Signature
export declare function getUserAddresses<Res extends AddressList = AddressList,
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 an Address List.
Referenced Types
Examples
Fetching customer addresses.
import { sdk } from '~/sdk';
const { addresses } = await sdk.commerce.getUserAddresses();Fetching customer addresses and selecting response fields.
import { sdk } from '~/sdk';
const { addresses } = await sdk.commerce.getUserAddresses({ fields: 'addresses(firstName,lastName)' });