isSubscribed(): Promise<TResponseStatus | undefined>¶
The isSubscribed method is asynchronous and returns information about whether the product is currently present in the favorites list.
Input parameters¶
stockId¶
string stockId - identifier of the product variant we want to check for in the favourites list
Returned value¶
A returned value has a type of Promise<TResponseStatus | undefined>. Find out more about TResponseStatus type here.
Example¶
In this example we make a AddToFavouritesApi call to check whether a product with stockId 10 is added to the favourites list. If it is not, we perform another call to add it to the list.
useStorefront(async (storefront) => {
    const favouritesApi = await storefront.getApi('AddToFavouritesApi');
    const isSubscribed = await favouritesApi.isSubscribed(10);
    if (isSubscribed === false) {
        await favouritesApi.subscribe(10);
    }
});