I am using ng-recaptcha package in order to implement Google reCAPTCHA V3 in my web app. For that I created a Service with will perform all the needed actions on the client side.
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { ReCaptchaV3Service, OnExecuteData } from 'ng-recaptcha';
import { environment } from 'src/environments/environment';
const BACKEND_URL = environment.apiUrl + '/contact/';
@Injectable()
export class ContactService {
constructor(
private http: HttpClient,
private recaptchaV3Service: ReCaptchaV3Service
) {}
public sendContactForm(data): void {
this.recaptchaV3Service.execute('contactForm').subscribe(data => {
console.log(data);
});
// this.http.post(BACKEND_URL, data)
// .subscribe((responseData) => {
// console.log(responseData);
// });
}
}
Unfortunatelly, when executing recaptcha (on sendContactForm method), I get the following error:
"Uncaught (in promise): [object Null]"
What is wrong here?