getUser(): User | null¶
The getUser
method allows you to get the data of currently authenticated user.
Returned value¶
A returned value has a type of User | null
. User
represents the User model and null
is returned when no user is authenticated.
Example¶
In this example we make a UserApi
call to get the email of an authenticated user.
useStorefront(async (storefront) => {
const userApi = await storefront.getApi('UserApi');
const user = userApi.getUser();
if (user) {
console.log('email of the user:', user.email)
}
});
User API methods reference¶
- selectUser$
- getOrders
- selectOrders$
- getAddresses
- selectAddresses$
- isProductNotificationPossible
- selectIsProductNotificationPossible$
- getLoyaltyPoints
- selectLoyaltyPoints$