selectAddresses$(): Promise<Observable<UserAddress[]>>¶
The selectAddresses$ method allows you to get the observable with the addresses of currently authenticated user.
Returned value¶
A returned value has a type of Promise<Observable<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 current default shipping address of an authenticated user.
useStorefront(async (storefront) => {
const userApi = await storefront.getApi('UserApi');
const userAddresses$ = await userApi.selectAddresses$();
userAddresses$.subscribe((addresses) => {
const currentDefaultShippingAddress = addresses.find((address) => address.isShippingDefault);
console.log('first name on the current default shipping address:', currentDefaultShippingAddress.address.firstName)
});
});
User API methods reference¶
- getUser
- selectUser$
- getOrders
- selectOrders$
- getAddresses
- isProductNotificationPossible
- selectIsProductNotificationPossible$
- getLoyaltyPoints
- selectLoyaltyPoints$