fetch() error handling

This commit is contained in:
Ian Gulliver
2024-11-28 07:46:33 -06:00
parent 4a8621bac8
commit 21d7af74af

View File

@@ -142,6 +142,10 @@ function set(short, long) {
if (document.getElementById('short').value == oldShort && document.getElementById('long').value == oldLong) { if (document.getElementById('short').value == oldShort && document.getElementById('long').value == oldLong) {
await navigator.clipboard.writeText(`${window.location.origin}/${newShort}`); await navigator.clipboard.writeText(`${window.location.origin}/${newShort}`);
} }
}).catch((err) => {
setTimeout(() => {
set(short, long);
}, 5000);
}); });
const suggestParams = new URLSearchParams(); const suggestParams = new URLSearchParams();
@@ -159,7 +163,7 @@ function set(short, long) {
for (const short of (await resp.json()).shorts) { for (const short of (await resp.json()).shorts) {
appendShortItem(short, long); appendShortItem(short, long);
} }
}); }).catch((err) => {});
} }
function setShortItem(short, icon) { function setShortItem(short, icon) {