Magento – Magento 2 google recaptcha Console log ERROR grecaptcha.render is not a function

googlemagento2recaptcha

I have installed Magento officially released Google reCAPTCHA it's working fine, But when I browse directly two customer account creation page https://example.com/customer/account/create/ captcha is not loading for the first time if I refresh it's loading fine.

Console log ERROR:

enter image description here

reCaptcha.js:127 Uncaught TypeError: grecaptcha.render is not a function
    at UiClass.initCaptcha (reCaptcha.js:127)
    at reCaptcha.js:175

/vendor/msp/recaptcha/view/frontend/web/js/reCaptcha.js

Tried below link but no luck

https://stackoverflow.com/a/50224757/8237294

Best Answer

Try to find file ./view/frontend/web/js/reCaptcha.js in you project and change code:

            renderReCaptcha: function () {
                var me = this;

                if (this.getIsVisible()) {
                    var initCaptchaInterval = setInterval(function () {
                        if (window.grecaptcha) {
                            clearInterval(initCaptchaInterval);
                            me.initCaptcha();
                        }
                    }, 100);
                }
            },

set

if (window.grecaptcha && window.grecaptcha.render ) {...}
Related Topic