Despite reading numerous answered questions on Stack Overflow, I am still struggling to resolve this issue. My problem arises from trying to call a function in Vue that returns a promise instead of the expected boolean value needed to disable a button. How can I convert the returned promise into a boolean?
<v-btn
medium
color="white"
style="overflow: hidden"
@click="runValidationTaskNow(index)"
:loading="isRunTaskBtnDisabled(index)"
:disabled="isRunTaskBtnDisabled(index)"
>RUN NOW
......
Within my methods, I utilize the mentioned function for disabling and loading.
async isRunTaskBtnDisabled(index) {
const Status = await Util.checkFeatureEnabled("Validate "+this.validationTasks[index].productName);
// Status.then(value => value);
return Status;
The checkFeatureEnabled function called above resides in another file, as shown 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));
In this code snippet, the response.data
contains either true or false values retrieved accurately from the database.