Skip to content

getToken(action: string): Promise<string>

The getToken is an asynchronous method which allows to execute Recaptcha on a given action and return a token.

Input parameters

action

string represents the action on which Recaptcha will be executed.

Returned value

A returned value has a type of Promise<string> which represents the returned Recaptcha token.

Example

In this example we make a RecaptchaV3Api call to execute the Recaptcha and retrieve a token.

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

    const token = await recaptchaApi.getToken('submit');

    // Add your logic to submit to your backend server here.
});

Recaptcha API methods reference