From a1988e2352ac0df0ebc96594d39ed74ac98fd0a3 Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Mon, 2 Mar 2020 16:59:10 +0100 Subject: Add populate_users call after songs are loaded --- dist/callback.html | 35 ++++++++++++++++++----------------- 1 file 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 = '

' + message.replace(/\n/g, '

\n

') + '

'; + }); + }); + + } 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 = '

' + message.replace(/\n/g, '

\n

') + '

'; - }); - }); - - } -- cgit v1.2.3-54-g00ecf