Skip to content

Instantly share code, notes, and snippets.

@asadbek064
Created July 23, 2020 19:44
Show Gist options
  • Select an option

  • Save asadbek064/5710ffd850a2e4f7a62b2bf9518af90b to your computer and use it in GitHub Desktop.

Select an option

Save asadbek064/5710ffd850a2e4f7a62b2bf9518af90b to your computer and use it in GitHub Desktop.
import { Component } from '@angular/core';
import { FormControl, FormGroup, FormBuilder, FormGroupDirective, NgForm, Validators } from '@angular/forms';
import { AuthService } from './auth.service';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
title = 'myProject';
myForm: FormGroup;
constructor(
private formBuilder: FormBuilder,
private authService: AuthService
) {
this.myForm = this.formBuilder.group({
name: ['', Validators.required],
reCAPTACH: ['', Validators.required]
});
}
// function to resolve the reCaptcha and retrieve a token
resolved(captchaResponse: string) {
console.log(`Resolved response token: ${captchaResponse}`);
this.sendTokenToBackend(captchaResponse);
}
// function to send the token to the node server
sendTokenToBackend(tok) {
// calling the service and passing the token to the service
this.authService.sendToken(tok).subscribe(
result => {
console.log(result.success);
},
err => {
console.log(err);
}
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment