Created
July 23, 2020 19:44
-
-
Save asadbek064/5710ffd850a2e4f7a62b2bf9518af90b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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