nuxt-community/recaptcha-module

$recaptcha.getResponse() rejected with `undefined` when used wrong key

zoxon opened this issue · 2 comments

zoxon commented
async onSubmit() {
  try {
    const token = await this.$recaptcha.getResponse();
    this.recaptcha = token;

    console.log(this.$data);
  } catch (error) {
    console.log(error); // undefined
  }
}

Configuration

{
  siteKey: "6LeXSaMZAAAAAKSyzQHnpkZKIN7bbnXq3nm1O6Go",
  size: "invisible",
  hideBadge: true,
  version: 2
}

Reproduction url
https://codesandbox.io/s/falling-water-p3zl4?file=/pages/index.vue:998-1039

There seems to be a general problem with error handling. These are some errors I got when I used a key that did not have proper domains configured:

image

image

The Uncaught exception and null error is related to recaptcha and the reason is you are using invalid site key.
There is some situation that this error raises, Check this question on stack: https://stackoverflow.com/questions/52390562/google-recaptcha-response-uncaught-in-promise-null