diff options
author | Dennis Kobert <dennis@kobert.dev> | 2020-03-02 16:59:10 +0100 |
---|---|---|
committer | Dennis Kobert <dennis@kobert.dev> | 2020-03-02 16:59:10 +0100 |
commit | a1988e2352ac0df0ebc96594d39ed74ac98fd0a3 (patch) | |
tree | 6b01c618debf97e46192b85551d3e856d2a5cac1 /dist/callback.html | |
parent | a09c4a1304d2697231aacf520357c6f21dfb9784 (diff) |
Add populate_users call after songs are loaded
Diffstat (limited to 'dist/callback.html')
-rw-r--r-- | dist/callback.html | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/dist/callback.html b/dist/callback.html index ec2e584..43e2aa5 100644 --- a/dist/callback.html +++ b/dist/callback.html @@ -88,6 +88,23 @@ body { document.getElementById("Connect_button").disabled = true; window.location = "https://kobert.dev/spotify-api/token/" + token; } + function populate_users() { + if (getParameterByName("code") != null) { + document.getElementById("Connect_button").disabled = true; + document.getElementById("Load_button").disabled = false; + } + fetch("https://kobert.dev/spotify-api/user") + .then(function(response) { + if (!response.ok) { + document.getElementById("status").innerHTML = `Error occured while loading songs: ${response.status}`; + throw new Error(`HTTP error! status: ${response.status}`); + } + response.text().then(function(message) { + document.getElementById("userlist").innerHTML = '<p>' + message.replace(/\n/g, '</p>\n<p>') + '</p>'; + }); + }); + + } function load_songs() { console.log("loading songs"); @@ -101,6 +118,7 @@ body { throw new Error(`HTTP error! status: ${response.status}`); } document.getElementById("status").innerHTML = "Loaded songs"; + populate_users(); }); //window.location = "https://kobert.dev/spotify-api/token/" + token; } @@ -119,23 +137,6 @@ function match_users() { }); }); } - function populate_users() { - if (getParameterByName("code") != null) { - document.getElementById("Connect_button").disabled = true; - document.getElementById("Load_button").disabled = false; - } - fetch("https://kobert.dev/spotify-api/user") - .then(function(response) { - if (!response.ok) { - document.getElementById("status").innerHTML = `Error occured while loading songs: ${response.status}`; - throw new Error(`HTTP error! status: ${response.status}`); - } - response.text().then(function(message) { - document.getElementById("userlist").innerHTML = '<p>' + message.replace(/\n/g, '</p>\n<p>') + '</p>'; - }); - }); - - } </script> </body> </html> |