i’m inserting recaptcha invisible at one system, but i need to get the secrets from database.
I have one method getting the value, but i need to save it in a const and pass to recaptcha method.
what i did, is not working.
how is working:
RecaptchaSiteKeyApi.js – Getting the key from backend api – here is working.
import { api } from './ApiConfig'
export default {
listaSiteKey: () =>
api.get(`recaptcha-site-key`,
{
headers: { Authentication: window.localStorage.getItem('token'), "Content-Type": "application/json" },
transformResponse: [function (data) {
const result = data ? JSON.parse(data) : null;
return result.nmSite;
}]
}),
}
RecaptchaSiteKey.js – to save the result from Api in a const and send to LoginPage –here is not working the value from listasitekey() not apear.
import RecaptchaSiteKeyApi from './RecaptchaSiteKeyApi';
const CHAVE_RECAPTCHA = {
key: null
}
export function carregarChaveCaptcha() {
if(CHAVE_RECAPTCHA.key==null){
CHAVE_RECAPTCHA.key = RecaptchaSiteKeyApi.listaSiteKey();
}
return CHAVE_RECAPTCHA.key;
}
Login.vue – here is the recaptcha method
i need to pass the value to these component:
<RecaptchaEnterprise
:data-sitekey="constKey()" <------- need to put the value key here
:data-validate="validate"
:data-callback="callback"
data-badge=""
>Acessar
</RecaptchaEnterprise>
</v-btn>
export default {
components: {
RecaptchaEnterprise
},
data() {
return {
key: null,
};
},
methods: {
constKey(){
const Key = carregarChaveCaptcha();
return Key
},
Debug:
RecaptchaSiteKey – not get the value from SiteKeyApi
RecaptchaSiteKeyApi – is getting the value from database