From 6717e0064741b0c3dd4b09a71b0f571c9195da7c Mon Sep 17 00:00:00 2001 From: Tyler-A Date: Sun, 9 Aug 2020 00:57:04 -0600 Subject: [PATCH] Move the API token getter to the globals mixin. --- src/components/ControlBar.vue | 2 +- src/main.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/ControlBar.vue b/src/components/ControlBar.vue index 8e53772..2344c0c 100644 --- a/src/components/ControlBar.vue +++ b/src/components/ControlBar.vue @@ -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 = ``; diff --git a/src/main.js b/src/main.js index 95dfaf8..c5ff457 100644 --- a/src/main.js +++ b/src/main.js @@ -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); }, - } + }, });