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/mon/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);
// });
}
}
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/mon/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?
Share Improve this question asked Dec 25, 2019 at 12:48 Ron RofeRon Rofe 7962 gold badges10 silver badges26 bronze badges 2- 1 can you create a sample demo on stackblitz – Allabakash Commented Dec 25, 2019 at 13:58
- Does this answer your question? Google reCaptcha response "Uncaught (in promise) null" – EliteRaceElephant Commented Feb 27, 2020 at 23:56
2 Answers
Reset to default 5This errors occurs when a site is not "registered" in the Google recaptcha/admin Domains area.
Solution: Add the domain in the recaptcha admin area:
- Sign into your Google account where your recaptcha keys are registered
- Type into Google "google recpatcha admin console"
- Go to your settings for your (production) key
- In "Domains", add these two entries:
localhost 127.0.0.1
- Save it and test your recaptcha.
There is another question that asks the same thing and requires the same solution.
You need to add your domain to the recaptcha admin console.
Don't forget to add localhost
for your test.