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-stringan ID of the product we want to ratereview-stringrepresents the review we want to add to a given productreviewer-stringrepresents a user name or a nickname of a reviewerchallenge-stringthe 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:
- FlashMessengerApi.addFlashMessage - when handling messages that come from a server
- FlashMessengerApi.addFlashMessages - when handling messages that come from a server
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"
});
});