vue-recaptcha-v3 icon indicating copy to clipboard operation
vue-recaptcha-v3 copied to clipboard

Cannot destructure property 'executeRecaptcha'

Open gplusdotgr opened this issue 2 years ago • 9 comments

I'm using the plugin in a Vue component but inside an Astro app. Not sure if that plays a role. Here's what I'm getting as an error:

<script setup lang="ts">

import { VueReCaptcha, useReCaptcha } from "vue-recaptcha-v3"
const { executeRecaptcha, recaptchaLoaded } = useReCaptcha()

const recaptcha = async () => {
  // (optional) Wait until recaptcha has been loaded.
  await recaptchaLoaded()

  // Execute reCAPTCHA with action "login".
  const token = await executeRecaptcha("login")

  console.log("token", token)
}

</script>
12:25:26 [ERROR] Cannot destructure property 'executeRecaptcha' of '__vite_ssr_import_9__.useReCaptcha(...)' as it is undefined.

gplusdotgr avatar Feb 28 '24 10:02 gplusdotgr

同样的问题,你的解决了吗

dayhi avatar Mar 05 '24 07:03 dayhi

same issue

Akulko avatar Mar 06 '24 15:03 Akulko

Just installed the library, same issue here.

I believe the problem is that executing useReCaptcha() returns "undefined"

mcorraodab avatar Mar 06 '24 22:03 mcorraodab

same issue

zapaza avatar Apr 15 '24 14:04 zapaza

Same issue here, can confirm what @mcorraodab said, useRecaptcha() returns a null, so docs for vue3 composition api are wrong.

Anyone solved this?

xfudox avatar Jun 25 '24 10:06 xfudox

Solution :

import { useReCaptcha } from 'vue-recaptcha-v3';

const reCaptcha = useReCaptcha();

const login = async () => {
  await reCaptcha.recaptchaLoaded();

  const token = await reCaptcha.executeRecaptcha('login');

  console.log('token', token);
}

cedroux avatar Aug 06 '24 16:08 cedroux