I have two API get methods. The first is to check if the user is an admin. The second is to call all the user lists.
But I am having a hard time calling first; It always calls all the user lists before I check if the user is admin or not.
What I did was
async mounted() {
await this.getCurrentUser();
}
and method to check if user is admin:
getCurrentUser(){
Common.getUser().then(data => {
if(!data.admin){
this.isAdmin = false;
}
});
},
method to get all users:
paging: function (pageNumber) {
vm.requestParam.page = pageNumber == undefined ?
var param = Common.param(vm.requestParam);
axios.get('/api/users?' + param).then(function (response) {
///
}
})
.catch(function (error) {
console.log(error.response);
});
},
and the data is:
data: {
resources: {},
'requestParam': {
'id': '',
'query': '',
'accessLevel': '',
'page': 1
},`