From e9d571ee25e953dddf20ea6048e194771a552cc0 Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Thu, 13 Feb 2020 00:01:01 +0000 Subject: Use promise to display list --- dist/callback.html | 8 +++++--- 1 file 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; + }); }); } -- cgit v1.2.3-54-g00ecf