Skip to content

getDiscountedProducts(options?: TGetProductsOptions): Promise<TWebapiList<Product> | null>

The getDiscountedProducts is an asynchronous method that allows to fetch a list of products undergoing a promotion.

Input parameters

options - an optional object with additional options for the request. You can read more about TGetProductsOptions object here.

Returned value

A returned value has a type of Promise<TWebapiList<Product> | null>. You can read more about TWebapiList object here.

Example

In this example we make a ProductFetcherApi call to get products undergoing a promotion.

useStorefront(async (storefront) => {
    let productFetcherApi = await storefront.getApi('ProductFetcherApi');

    if (!productFetcherApi) {
        const featureSystemApi = storefront.getApiSync('FeatureSystemApi');
        await featureSystemApi.registerDynamic('ProductFetcher');

        productFetcherApi = await storefront.getApi('ProductFetcherApi');
    }

    const products = await productFetcherApi.getDiscountedProducts();
    console.log(products);
});

Product Fetcher API methods reference

Objects reference