From af7d1b2f2358d98b9dd806d521f417e74c89c802 Mon Sep 17 00:00:00 2001 From: Jonas Leder <jonas@jonasled.de> Date: Sun, 28 Aug 2022 16:37:49 +0200 Subject: [PATCH] update for new url shorter API --- src/popup.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/popup.js b/src/popup.js index e77ab09..eaa4025 100644 --- a/src/popup.js +++ b/src/popup.js @@ -10,21 +10,18 @@ async function shortURL() { xhr.onreadystatechange = () => { if(xhr.readyState == 4){ if(xhr.status == 200){ - const response = JSON.parse(xhr.responseText); - - urlField.value = response.url; + urlField.value = xhr.responseText; urlField.focus(); urlField.select(); - QRCode.toCanvas(qrCanvas, response.url); + QRCode.toCanvas(qrCanvas, xhr.responseText); } else { alert("Error: " + xhr.status + "\n" + xhr.responseText); } } }; xhr.open("POST", "https://jle.xyz/user/api", true); - xhr.setRequestHeader("Content-Type", "application/json"); - xhr.send(JSON.stringify({ "long": url })); + xhr.send(url); } -document.addEventListener("DOMContentLoaded", shortURL); \ No newline at end of file +document.addEventListener("DOMContentLoaded", shortURL); -- GitLab