Skip to content

review(props: TReviewProps): Promise<TResponseStatus | undefined>

The review is an asynchronous method which allows to review a given product.

Input parameters

props

props is an object of the TReviewProps type which contains the following fields:

  • productId - string an ID of the product we want to rate
  • review - string represents the review we want to add to a given product
  • reviewer - string represents a user name or a nickname of a reviewer
  • challenge - string the Recaptcha value sent if Recaptcha is configured and active in the shop. Read more about Recaptcha V3 in the Recaptcha API documentation page

Returned value

A returned value has a type of Promise<TResponseStatus | undefined>. Find out more about TResponseStatus type here.

Event Bus events

This API method dispatches the following events with the Event Bus:

Example

In this example we make a RateAndReviewApi call to review the given product.

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

    await rateAndReviewApi.review({
        productId: "145",
        review: "I recommend this product!",
        reviewer: "Zenek",
        challenge: "xYz"
    });
});

Rate And Review API methods reference

Objects reference

APIs reference