Skip to content

Instantly share code, notes, and snippets.

@fhsinchy
Last active August 28, 2021 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fhsinchy/59f56d754cb718f088a12966537771b8 to your computer and use it in GitHub Desktop.
Save fhsinchy/59f56d754cb718f088a12966537771b8 to your computer and use it in GitHub Desktop.
// src/views/Home.vue
<script>
import axios from 'axios';
import { store, getters } from '@/store';
export default {
async mounted() {
if (this.isLoggedIn) {
try {
const response = await axios.get(`${process.env.VUE_APP_OAUTH_AUTH_SERVER}/api/user`, {
headers: {
Authorization: `Bearer ${store.accessToken}`,
},
});
this.user = response.data;
} catch (error) {
console.log(error);
}
}
},
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment