I created plugin that let me check if user has permission to do some action. Plugin use axios to check permission on server and return true or false.
But I have a problem because "if" statement dosen't wait for function "$guard()" is completed. And as a result I have information "Promise { : "pending" }" instead of boolean.
publicGame()
{
                console.log(this.$guard('Moderate games'));
                if(this.$guard('Moderate games') === true){
                    console.log('can')
                }else{
                    console.log('can not')
                }
}
plugin:
export default {
    Auth,
    install (Vue, options) {
        Vue.prototype.$guard = async function(permission){
           await axios.post('/permission',{permission: permission},{ headers: {
                'X-Requested-With': 'XMLHttpRequest',
                "X-CSRF-TOKEN": Auth.state.token
            }}).then(response=>{                
                return response.data.access === 1;
            }).catch(function (error) {
                console.log(error);
            });
        }
    }
}
So how to fix this function to wait for ajax request complete?
Thank you.
 
     
     
    