Created
October 4, 2020 03:16
-
-
Save blogcacanid/5a4a146c4e4afec051731c527b219c98 to your computer and use it in GitHub Desktop.
HomeComponent.vue - Login System Dengan JSON Web Token Laravel 7 Dan Vue - 02 Front End
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-md-8 col-md-offset-2"> | |
<h1>Home</h1> | |
<p> | |
<router-link :to="{ name: 'logout' }">Logout</router-link> | |
</p> | |
<div class="panel panel-default"> | |
<div class="panel-heading">Home</div> | |
<div class="panel-body"> | |
<p>Data: ""</p> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</template> | |
<script> | |
export default { | |
data() { | |
return { | |
data: 'nothing' | |
} | |
}, | |
mounted() { | |
axios.get('/api/auth/profile', { | |
headers: { | |
Authorization: 'Bearer ' + localStorage.getItem('token') | |
} | |
}) | |
.then(response => { | |
this.data = response.data.data | |
}).catch(error => { | |
}) | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment