最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - ng-recaptcha ERR: Error: "Uncaught (in promise): [object Null]" - Stack Overflow

programmeradmin3浏览0评论

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
Add a ment  | 

2 Answers 2

Reset to default 5

This errors occurs when a site is not "registered" in the Google recaptcha/admin Domains area.

Solution: Add the domain in the recaptcha admin area:

  1. Sign into your Google account where your recaptcha keys are registered
  2. Type into Google "google recpatcha admin console"
  3. Go to your settings for your (production) key
  4. In "Domains", add these two entries:
localhost
127.0.0.1
  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.

发布评论

评论列表(0)

  1. 暂无评论