Move the API token getter to the globals mixin.
This commit is contained in:
parent
aa9204fcfe
commit
6717e00647
2 changed files with 8 additions and 2 deletions
|
|
@ -170,7 +170,7 @@ export default {
|
|||
this.$nextTick(function() {
|
||||
axios.get(
|
||||
`${this.api_url}/me`,
|
||||
{ headers: { Authorization: `Bearer ${this.token}` } }
|
||||
{ headers: { Authorization: `Bearer ${this.api_token}` } }
|
||||
).then((response) => {
|
||||
if (response.error) {
|
||||
window.location.hash = ``;
|
||||
|
|
|
|||
|
|
@ -16,11 +16,17 @@ Vue.mixin({
|
|||
api_url: `https://api.spotify.com/v1`,
|
||||
auth_redirect: process.env.NODE_ENV === `production` ? `https://oliver.akins.me/top-lists` : `http://localhost:8080`,
|
||||
}},
|
||||
computed: {
|
||||
api_token() {
|
||||
let params = new URLSearchParams(window.location.hash.slice(1));
|
||||
return params.get(`access_token`);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
css_var(var_name) {
|
||||
return getComputedStyle(document.documentElement).getPropertyValue(var_name);
|
||||
},
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue