I'm trying to integrate reCaptcha V3
what I tried is:
<script defer="defer"
type="text/javascript"
src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=6Lda2XgUAAAAAKxRqwe9zBL09zv2ja1DYV-r">
</script>
<script type="text/javascript">
var onloadCallback = function(){
grecaptcha.execute('6Lda2XgUAAAAAKxRaqwev2ja1DYV-r', {action: '/foo/bar/'}).then(function(token) {
alert(token)
});
};
</script>
But on loading page I get (index):1 Uncaught (in promise) null
Does somebody know the reason and how could i fix it?
EDIT: I catched this error:
Uncaught TypeError: grecaptcha.execute(...).then(...).catch is not a function
at onloadCallback ((index):18)
at gf (recaptcha__pl.js:512)
at Gj (recaptcha__pl.js:508)
at recaptcha__pl.js:520
at recaptcha__pl.js:539
onloadCallback @ (index):18
gf @ recaptcha__pl.js:512
Gj @ recaptcha__pl.js:508
(anonymous) @ recaptcha__pl.js:520
(anonymous) @ recaptcha__pl.js:539
(index):1 Uncaught (in promise) null
grecaptcha.execute is created in the first script
the defer attribute will wait for page to load before executing it.
So removing the defer should make it.
Note: defer is not appearing in the official integration documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With