Skip to content

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

The getBestsellers is an asynchronous method that allows to fetch a list of bestsellers.

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 bestsellers.

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.getBestsellers();
    console.log(products);
});

Product Fetcher API methods reference

Objects reference