Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
The second implementation option for the article: https://kolmogorov.pro/integration_google_recaptcha_v3_in_site_on_vue_js
let reCaptcha = new Promise((resolve, reject) => {
const $script = document.createElement('script')
$script.src = 'https://www.google.com/recaptcha/api.js?render=ВАШ_КЛЮЧ'
resolve(document.head.appendChild($script));
setTimeout(() => reject(new Error("Google reCaptcha не инициализирована")), 3000);
});
reCaptcha
.then(
result => {
setTimeout(() => {
grecaptcha.ready(function() {
grecaptcha.execute('ВАШ_КЛЮЧ', {action: 'homepage'}).then(function(token) {
axios
.post('/functions/recaptcha.php', {
token: token
})
.catch(() => {
console.log('POST-запрос в API Google не был отправлен.');
})
});
});
}, 1000)
},
error => {
console.log(error);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.