Search Posts

How to use .then method for vcRecaptchaService.execute()?

I am using anuglar-recaptcha for adding Google Invisible Recaptcha to my login form

The issue I am facing is, immediately after I call vcRecaptchaService.execute, if I print the recaptcha_reponse I will see undefined as output. But if I print recaptcha_reponse few seconds afterwards by using a test function printRecaptchaReponse I will see the recaptcha_reponse getting printed.

The Issue here is, the library function vcRecaptchaService.execute() is not returning a $promise here. Its actually returning none

Is there any way to promisify this ?

Whats the ISSUE:

// 1. Call this function from html first
$scope.testRecaptchaExecute = function() {
    vcRecaptchaService.execute($scope.widgetId);
    console.log($scope.user.recaptcha_reponse);
    // undefined :-(
    return();
}

// 2. Call this function from html few seconds after testRecaptchaExecute() is called

$scope.printRecaptchaReponse = function() {
    console.log($scope.user.recaptcha_reponse);
    //JVRk4cZ4J_RluoH2
}

WHAT I want:
Something like,

vcRecaptchaService.execute().then(ret => { //do something here })
Issue with this code is vcRecaptchaService.execute don’t return a promise. This code won’t work

Question Summary
How to use .then method for vcRecaptchaService.execute()?

Source: AngularJS

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.