Skip to content

getProducts(productsId: number[], options?: TGetProductsOptions): Promise | null>

The getProducts is an asynchronous method that allows to fetch a list of products by their ids.

Input parameters

productsId - an array of numbers representing the product ids.

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

Returned value

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

Example

In this example we make a ProductFetcherApi call to get products with ids 1 and 2.

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

    const products = await productFetcherApi.getProducts([1, 2]);
    console.log(products);
});

Product Fetcher API methods reference

Objects reference