I have a Vue component for a sidebar with a template defined as:
Vue.component('navigation',{
template:`
<ul class="nav">
<li v-if="checkIfUserIsAdmin() == true" id="adminMenu"></li>
<li id="userMenu"></li>
`,
methods: {
checkIfUserIsAdmin() {
var result = false;
axiosInstance.get("/Profile/GetUserInfo").then(userInfo => {
result = userInfo.data.u.isAdmin;
})
.catch(userError => {
swal({
title: "Operational Platform",
text: "Unable to retrieve user info"
});
result = false;
});
return result;
}
}
});
Some code was removed for brevity.
When I visit the /Profile/GetUserInfo I get a JSON in return that's properly returning me true but the adminMenu is not displaying and I'm wondering why. It seems that the v-if is the place that I've messed up. I've tried also changing the adminMenu to have v-if="checkIfUserIsAdmin() == 'true'" but it still didn't work.
v-if="async function"