mirror of
https://github.com/SinTan1729/chhoto-url
synced 2024-12-26 23:58:35 -06:00
fix: Errors in script.js
This commit is contained in:
parent
30c0b8b50a
commit
86ec787d96
1 changed files with 7 additions and 7 deletions
|
@ -173,6 +173,7 @@ const submitForm = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const url = prepSubdir("/api/new");
|
const url = prepSubdir("/api/new");
|
||||||
|
let ok = false;
|
||||||
|
|
||||||
fetch(url, {
|
fetch(url, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
@ -182,15 +183,14 @@ const submitForm = () => {
|
||||||
body: JSON.stringify(data),
|
body: JSON.stringify(data),
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (!res.ok) {
|
ok = res.ok;
|
||||||
showAlert(res.text(), "red");
|
return res.text();
|
||||||
return "error";
|
})
|
||||||
|
.then(text => {
|
||||||
|
if (!ok) {
|
||||||
|
showAlert(text, "red");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return res.text();
|
|
||||||
}
|
|
||||||
}).then(text => {
|
|
||||||
if (text != "error") {
|
|
||||||
copyShortUrl(text);
|
copyShortUrl(text);
|
||||||
longUrl.value = "";
|
longUrl.value = "";
|
||||||
shortUrl.value = "";
|
shortUrl.value = "";
|
||||||
|
|
Loading…
Reference in a new issue