Skip to content

addComment(articleId: string, commentProps: TCommentProps): Promise<TResponseStatus | undefined>

The addComment method adds a comment under a blog article.

Input parameters

articleId

articleId is a mandatory parameter of the string type which represents an id of the blog article we are currently browsing.

commentProps

commentProps is a mandatory parameter of TCommentProps type which tells the api what is the content of the comment we are trying to add.

Returned value

A returned value is has a type of Promise<TResponseStatus | undefined>. You can learn more about TResponseStatus here.

Event Bus events

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

Example of usage

    useStorefront(async (storefront) => {
        const blogCommentFormApi = storefront.getApiSync('BlogArticleCommentFormApi');

        await blogCommentFormApi.addComment({
            user: 'Author',
            comment: `This is my comment`
        });
    });

Objects reference