Added error alert logic
This commit is contained in:
parent
e308b7b448
commit
c48527ad0c
14
main.js
14
main.js
|
@ -55,18 +55,14 @@ function createUrl() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
document.getElementById("error_dismiss").onclick = () =>{
|
||||||
|
document.getElementById("error_container").classList.add("hidden");
|
||||||
|
};
|
||||||
function handleError(res) {
|
function handleError(res) {
|
||||||
if (res.status == 400) {
|
if (res.status == 400) {
|
||||||
res.text().then((body)=>{
|
res.text().then((body)=>{
|
||||||
switch (body) {
|
document.getElementById("error_text").innerText=body;
|
||||||
case "Shortcode already exists, please choose another code":
|
document.getElementById("error_container").classList.remove("hidden");
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue