summaryrefslogtreecommitdiff
path: root/dist/callback.html
diff options
context:
space:
mode:
Diffstat (limited to 'dist/callback.html')
-rw-r--r--dist/callback.html11
1 files changed, 10 insertions, 1 deletions
diff --git a/dist/callback.html b/dist/callback.html
index 002515c..6960d81 100644
--- a/dist/callback.html
+++ b/dist/callback.html
@@ -3,6 +3,7 @@
<body>
<h1>Spotify Intersect</h1>
<button onclick="load_songs()">Load songs to database</button>
+ <p id="p1"></p>
<script>
function getParameterByName(name) {
let url = window.location.href;
@@ -16,8 +17,16 @@
function load_songs() {
console.log("loading songs");
+ document.getElementById("p1").innerHTML = "Loading songs";
let token = sessionStorage.getItem('token');
- fetch("https://kobert.dev/spotify-api/callback/" + token + "/" + getParameterByName("code")).then(console.log("finished loading songs!"));
+ fetch("https://kobert.dev/spotify-api/callback/" + token + "/" + getParameterByName("code"))
+ .then(function(response) {
+ if (!response.ok) {
+ throw new Error(`HTTP error! status: ${response.status}`);
+ document.getElementById("p1").innerHTML = "Error occured while loading songs: ${response.status}";
+ }
+ document.getElementById("p1").innerHTML = "Loaded songs";
+ });
//window.location = "https://kobert.dev/spotify-api/token/" + token;
}
</script>