79534184

Date: 2025-03-25 15:50:11
Score: 4
Natty: 4
Report link

In vue3.js
Same than as @Halfer I import VueReCaptcha in main.js.
Then in my component I give it a try.

SO I guess I need to verify if the token is available ?? How to do ? a post request to https://www.google.com/recaptcha/api/siteverify ?
see https://developers.google.com/recaptcha/docs/verify

 <template><button type="button" @click="recaptcha">reCAPTCHA</button></template>
<script>
export default {
  methods: {
    async recaptcha() {
      // (optional) Wait until recaptcha has been loaded.
      await this.$recaptchaLoaded();

      // Execute reCAPTCHA with action "login".
      const token = await this.$recaptcha('login');
      const data = {
        secret:'<my_secret_id>',
        response:token
      }
      
      // I guess I need to verify if the token is available ?? //
       const response = await fetch('https://developers.google.com/recaptcha/docs/verify',
        {
            method:'POST',
            body: JSON.stringify(data)
        });
       if (!response.success){ return; }

        // Go ahead with submission .... //

    },
   }
}
</script>
Reasons:
  • Blacklisted phrase (0.5): I need
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • User mentioned (1): @Halfer
  • Low reputation (0.5):
Posted by: Robert