successdav
5 days ago
62
2
Vue

GET INLINE JAVASCRIPT VALUE TO VUE COMPONENT

Posted 5 days ago by successdav

I have this javascript code generating google captcha token on my register.blade.php page and the component registered here on this same page. I am adding the javascript code to the head section of my website using @section.

@extends('layouts.app')

@section('head')
    <script src="https://www.google.com/recaptcha/api.js?render=6LeawrcUAAAAAIrA-LQ-kytjPFEBcedXDLcWHHHM"></script>
@endsection

@section('body-close')
    <script>
      grecaptcha.ready(function() {
          grecaptcha.execute('6LeawrcUAAAAAIrA-LQ-kytjPFEBcedXDLcWHHHM', {action: 'homepage'}).then(function(token) {
                console.log(token);
                //I want to get the value generated from this script
          });
      });
      // grecaptcha.ready();
    </script>
@endsection

@section('content')
    <input type="hidden" name="token" id="token" value="">
    <site-registration></site-registration>
@endsection

I want the token generated from this javascript code

<script>
      grecaptcha.ready(function() {
          grecaptcha.execute('6LeawrcUAAAAAIrA-LQ-kytjPFEBcedXDLcWHHHM', {action: 'homepage'}).then(function(token) {
                console.log(token);
                //I want to get the value generated from this script
          });
      });
      // grecaptcha.ready();
</script>

To be passed unto this component registered on the same page

<site-registration></site-registration>

then assign the value to my Form here

<template>
</template>
<script>
    export default {
        data () {
            return {
                errorMessage: '',
                submitting: '',
                RegForm: new Form ({
                    emailOrPhone:'[email protected]',
                    surname:'success',
                    lastname:'daviso',
                    middlename: 'feaf',
                    phone: '09050689896',
                    gender:'M',
                    dateofbirth:'',
                    password:'0000000000',
                    password_confirmation:'0000000000',
                    token:'',
                })
            }
        },
</script>

Thanks for your help

Please sign in or create an account to participate in this conversation.