Added error alert logic

This commit is contained in:
Nicolai Ort 2021-08-17 19:42:02 +02:00
parent e308b7b448
commit c48527ad0c
Signed by: niggl
GPG Key ID: 13AFA55AF62F269F
1 changed files with 5 additions and 9 deletions

14
main.js
View File

@ -55,18 +55,14 @@ function createUrl() {
}
document.getElementById("error_dismiss").onclick = () =>{
document.getElementById("error_container").classList.add("hidden");
};
function handleError(res) {
if (res.status == 400) {
res.text().then((body)=>{
switch (body) {
case "Shortcode already exists, please choose another code":
break;
default:
break;
}
document.getElementById("error_text").innerText=body;
document.getElementById("error_container").classList.remove("hidden");
})
}
}