Skip to content

getAddresses(): Promise<UserAddress[]>

The getAddresses method allows you to get the addresses of currently authenticated user.

Returned value

A returned value has a type of Promise<UserAddress[]> where UserAddress represents the extension of the Address model specified in the User model documentation.

Example

In this example we make a UserApi call to get the default shipping address of an authenticated user.

    useStorefront(async (storefront) => {
        const userApi = await storefront.getApi('UserApi');

        const userAddresses = await userApi.getAddresses();

        const defaultShippingAddress = userAddresses.find((userAddress) => userAddress.isShippingDefault);

        console.log('first name on the default shipping address:', defaultShippingAddress.address.firstName)
    });

User API methods reference

Models reference