diff options
author | Dennis Kobert <dennis@kobert.dev> | 2020-02-13 00:01:01 +0000 |
---|---|---|
committer | Dennis Kobert <dennis@kobert.dev> | 2020-02-13 00:01:01 +0000 |
commit | e9d571ee25e953dddf20ea6048e194771a552cc0 (patch) | |
tree | fc0af9dc14b23d807c4d2c591eb63d19ff879b6a /dist/callback.html | |
parent | 9e786975ce77b699bd9805d92e6d275132362154 (diff) |
Use promise to display list
Diffstat (limited to 'dist/callback.html')
-rw-r--r-- | dist/callback.html | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/dist/callback.html b/dist/callback.html index 7bda9f3..eaf689b 100644 --- a/dist/callback.html +++ b/dist/callback.html @@ -27,7 +27,7 @@ fetch("https://kobert.dev/spotify-api/callback/" + token + "/" + getParameterByName("code")) .then(function(response) { if (!response.ok) { - document.getElementById("status").innerHTML = "Error occured while loading songs: ${response.status}"; + document.getElementById("status").innerHTML = `Error occured while loading songs: ${response.status}`; throw new Error(`HTTP error! status: ${response.status}`); } document.getElementById("status").innerHTML = "Loaded songs"; @@ -41,10 +41,12 @@ function match_users() { fetch("https://kobert.dev/spotify-api/match/" + name1 + "/" + name2) .then(function(response) { if (!response.ok) { - document.getElementById("status").innerHTML = "Error occured while loading songs: ${response.status}"; + document.getElementById("status").innerHTML = `Error occured while loading songs: ${response.status}`; throw new Error(`HTTP error! status: ${response.status}`); } - document.getElementById("output").innerHTML = response.body; + response.text().then(function(message) { + document.getElementById("output").innerHTML = message; + }); }); } </script> |