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.
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
}