Skip to content

askForProduct(askForProductProps: TAskForProductProps): Promise<TResponseStatus | undefined>

The askForProduct method allows you to ask for a given product via api.

Input parameters

askForProductProps

askForProductProps is a mandatory parameter of TAskForProductProps type which includes the properties of the product we are trying to ask for.

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

In this example we make a ProductAskQuestionsApi call to ask for a specific product.

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

        try {
            const status = await productAskQuestionsApi.askForProduct({
                productId: 12,
                askQuestionDetails: {
                    mail: 'email@example.com',
                    question: 'Is this available in a white version?'
                }
            });

            if (status === 'failed') {
                console.log('Failed to ask for product');
            }
        } catch(error) {
            console.log('Something went wrong', error);
        }
    });

Objects reference