summaryrefslogtreecommitdiff
path: root/dist/callback.html
diff options
context:
space:
mode:
authorDennis Kobert <dennis@kobert.dev>2020-02-12 19:47:49 +0000
committerDennis Kobert <dennis@kobert.dev>2020-02-12 19:47:49 +0000
commit80558027d43840c9b246a87068740cd39a033762 (patch)
tree670de1108c7513fdfc46c944e131a06a57b4c342 /dist/callback.html
parentea49190e439f24b7694b8f41a10c6205f2d98c9f (diff)
Add loading feedback
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>