mirror of
https://github.com/minoplhy/chhoto-url.git
synced 2024-11-22 09:16:46 +00:00
fix: Errors in script.js
This commit is contained in:
parent
30c0b8b50a
commit
86ec787d96
@ -173,6 +173,7 @@ const submitForm = () => {
|
||||
};
|
||||
|
||||
const url = prepSubdir("/api/new");
|
||||
let ok = false;
|
||||
|
||||
fetch(url, {
|
||||
method: "POST",
|
||||
@ -182,15 +183,14 @@ const submitForm = () => {
|
||||
body: JSON.stringify(data),
|
||||
})
|
||||
.then(res => {
|
||||
if (!res.ok) {
|
||||
showAlert(res.text(), "red");
|
||||
return "error";
|
||||
ok = res.ok;
|
||||
return res.text();
|
||||
})
|
||||
.then(text => {
|
||||
if (!ok) {
|
||||
showAlert(text, "red");
|
||||
}
|
||||
else {
|
||||
return res.text();
|
||||
}
|
||||
}).then(text => {
|
||||
if (text != "error") {
|
||||
copyShortUrl(text);
|
||||
longUrl.value = "";
|
||||
shortUrl.value = "";
|
||||
|
Loading…
Reference in New Issue
Block a user