summaryrefslogtreecommitdiff
path: root/dist/callback.html
diff options
context:
space:
mode:
Diffstat (limited to 'dist/callback.html')
-rw-r--r--dist/callback.html35
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>