getRecaptchaReadyInstance(): Promise<IReCaptchaInstance>¶
The getRecaptchaReadyInstance
method returns the Recaptcha instance when it's ready to be used.
Returned value¶
A returned value has a type of Promise<IReCaptchaInstance>
where IReCaptchaInstance
represents the IReCaptchaInstance object
Example¶
In this example we make a RecaptchaV3Api
call to retrieve the recaptcha instance.
useStorefront(async (storefront) => {
const recaptchaApi = await storefront.getApi('RecaptchaV3Api');
const recaptchaInstance = await recaptchaApi.getRecaptchaReadyInstance();
recaptchaInstance.ready(function() {
recaptchaInstance.execute('reCAPTCHA_site_key', { action: 'submit' }).then(function(token) {
// Add your logic to submit to your backend server here.
});
});
});