API routes now return proper Responses and basic errors are handled

slight improvements in layouting
This commit is contained in:
2023-07-02 23:39:31 +02:00
parent ece3b3634c
commit 24ddd39f35
12 changed files with 349 additions and 78 deletions

View File

@ -98,6 +98,15 @@
})
})
if(res.status === 200){
const url = location.href.split('/')
url.splice(url.length -2, 2);
location.assign(url.join('/'))
}
else{
const item = await res.json();
alert(item.message)
}
}
async function doEdit() {
const res = await fetch('/api/edit', {
@ -124,7 +133,15 @@
}
})
})
const item = await res.json();
if(res.status === 200){
const url = location.href.split('/');
url.splice(url.length -2, 1);
location.assign(url.join('/'))
}
else{
const item = await res.json()
alert(item.message)
}
}
</script>