简体   繁体   English

ng-recaptcha ERR:错误:“未捕获(承诺):[对象空]”

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

I am using ng-recaptcha package in order to implement Google reCAPTCHA V3 in my web app.我正在使用 ng-recaptcha 包来在我的网络应用程序中实现 Google reCAPTCHA V3。 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:不幸的是,在执行 recaptcha 时(在 sendContactForm 方法上),我收到以下错误:

"Uncaught (in promise): [object Null]" “未捕获(承诺):[对象空]”

在此处输入图片说明

What is wrong here?这里有什么问题?

This errors occurs when a site is not "registered" in the Google recaptcha/admin Domains area.当站点未在 Google recaptcha/admin Domains 区域中“注册”时,会发生此错误。

Solution: Add the domain in the recaptcha admin area:解决方法:在recaptcha管理区添加域:

  1. Sign into your Google account where your recaptcha keys are registered登录到您注册了重新验证码的 Google 帐户
  2. Type into Google "google recpatcha admin console"输入谷歌“google recpatcha 管理控制台”
  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 .您需要将您的域添加到 recaptcha 管理控制台

Don't forget to add localhost for your test.不要忘记为您的测试添加localhost

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 谷歌 reCaptcha 响应“未捕获(承诺)空” - Google reCaptcha response "Uncaught (in promise) null" “Uncaught (in promise): null” 提升 reCAPTCHA 的价值时 - “Uncaught (in promise): null” when lifting up the value of reCAPTCHA 错误:未捕获(承诺):[object Object] - Error: Uncaught (in promise): [object Object] 未捕获(承诺中)错误:reCAPTCHA 占位符元素必须是元素或 id - Uncaught (in promise) Error: reCAPTCHA placeholder element must be an element or id 错误:未捕获(承诺):[object Boolean] - Error: Uncaught (in promise): [object Boolean] 错误:错误错误:未捕获(承诺):[对象布尔] - Error : ERROR Error: Uncaught (in promise): [object Boolean] 吞下的消息:错误:未捕获(承诺):[对象未定义] - Swallowed message : Error: Uncaught (in promise): [object Undefined] ERROR 错误:未捕获(承诺中):TypeError:无法读取 null 的属性“isAdmin” - ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'isAdmin' of null 未被捕获(承诺):错误:找不到“ [对象对象]”的NgModule元数据 - Uncaught (in promise): Error: No NgModule metadata found for '[object Object]' 未捕获(承诺):服务器错误 - Uncaught (in promise): Server error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM