I have a Vue
component for a sidebar with the following template:
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 has been omitted for brevity.
When I make a request to /Profile/GetUserInfo
, I receive a JSON response that includes true
for the isAdmin value, but the adminMenu element is not being displayed. I suspect that the issue lies within the v-if
condition. I even attempted changing the condition to
v-if="checkIfUserIsAdmin() == 'true'"
, but this did not resolve the problem.