Skip to content

selectLoyaltyPoints$(): Observable<number | null>

The selectLoyaltyPoints$ method allows you to get the current amount of points in the loyalty program for a currently authenticated user.

Returned value

A returned value has a type of Observable<number | null> representing the current amount of points. null will be returned in the observable if the loyalty program is not active.

Example

In this example we make a UserApi call to get the points in the loyalty program.

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

        const loyaltyPoints$ = userApi.selectLoyaltyPoints$();

        loyaltyPoints$.subscribe((currentLoyaltyPoints) => {
            console.log('current amount of loyalty points:', currentLoyaltyPoints);
        })        
    });

User API methods reference