More rework

This commit is contained in:
Patrick Jentsch
2023-03-09 14:55:08 +01:00
parent fdad10991c
commit 59de68e6fa
11 changed files with 129 additions and 423 deletions

View File

@@ -11,6 +11,14 @@ Requests.JSONfetch = (input, init={}) => {
fetch(input, Utils.mergeObjectsDeep(init, fixedInit))
.then(
(response) => {
if (response.ok) {
resolve(response.clone());
} else {
reject(response);
}
if (response.status === 204) {
return;
}
response.json()
.then(
(json) => {
@@ -22,11 +30,6 @@ Requests.JSONfetch = (input, init={}) => {
app.flash(`[${response.status}]: ${response.statusText}`, 'error');
}
);
if (response.ok) {
resolve(response);
} else {
reject(response);
}
},
(response) => {
app.flash('Something went wrong', 'error');