0
0
Fork 0

Move the API token getter to the globals mixin.

This commit is contained in:
Tyler-A 2020-08-09 00:57:04 -06:00
parent aa9204fcfe
commit 6717e00647
2 changed files with 8 additions and 2 deletions

View file

@ -170,7 +170,7 @@ export default {
this.$nextTick(function() { this.$nextTick(function() {
axios.get( axios.get(
`${this.api_url}/me`, `${this.api_url}/me`,
{ headers: { Authorization: `Bearer ${this.token}` } } { headers: { Authorization: `Bearer ${this.api_token}` } }
).then((response) => { ).then((response) => {
if (response.error) { if (response.error) {
window.location.hash = ``; window.location.hash = ``;

View file

@ -16,11 +16,17 @@ Vue.mixin({
api_url: `https://api.spotify.com/v1`, api_url: `https://api.spotify.com/v1`,
auth_redirect: process.env.NODE_ENV === `production` ? `https://oliver.akins.me/top-lists` : `http://localhost:8080`, 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: { methods: {
css_var(var_name) { css_var(var_name) {
return getComputedStyle(document.documentElement).getPropertyValue(var_name); return getComputedStyle(document.documentElement).getPropertyValue(var_name);
}, },
} },
}); });