Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

407
Visualizações
How to return a boolean from axios to disable a button in vue

I read almost every answered question in stack overflow to solve this, but still, I cannot resolve this. I am trying to call a function to disable my button in vue and the function is returning a promise instead of a boolean. How can I get a boolean value here?

                        <v-btn
                        medium
                        color="white"
                        style="overflow: hidden"
                        @click="runValidationTaskNow(index)"
                        :loading="isRunTaskBtnDisabled(index)"
                        :disabled="isRunTaskBtnDisabled(index)"
                        >RUN NOW

......

In my methods, I call this function that I mentioned in disable and loading.

 async isRunTaskBtnDisabled(index) {
   const Status = await Util.checkFeatureEnabled("Validate "+this.validationTasks[index].productName);

  // Status.then(value => value);
   return Status;

and the checkFeatureEnabled is from another file that is given below

async checkFeatureEnabled(featureName){
const reqURL = process.env.VUE_APP_GUIDE_UTILITY_SERVICES_HOST + `/api/checkFeatureEnabled/` + featureName;
console.log("reqURL", reqURL);
return await Axios(reqURL, { method: "GET", withCredentials: true })
    .then((response) => {
      console.log("ui"+response.data);
    return response.data;
}).catch((error) => console.log(error));  

Here the response.data is true or false; I am getting that correctly from my DB.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

change this part

return await Axios(reqURL, { method: "GET", withCredentials: true })
    .then((response) => {
      console.log("ui"+response.data);
    return response.data;
}).catch((error) => console.log(error));  

to this:

try {
  const response = await Axios(reqURL, { method: 'GET', withCredentials: true })
  console.log('ui' + response.data)
  return response.data
} catch (e) {
  console.log(e)
  return something
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda