Spaces:
Running
Running
Update static/js/common.js
Browse files- static/js/common.js +7 -1
static/js/common.js
CHANGED
@@ -5,9 +5,15 @@ function apiPost(path, body) {
|
|
5 |
method: 'POST',
|
6 |
headers: { 'Content-Type': 'application/json' },
|
7 |
body: JSON.stringify(body)
|
8 |
-
}).then(res =>
|
|
|
|
|
|
|
|
|
|
|
9 |
}
|
10 |
|
|
|
11 |
function apiGet(path) {
|
12 |
return fetch(`${apiBase}${path}`)
|
13 |
.then(res => res.json());
|
|
|
5 |
method: 'POST',
|
6 |
headers: { 'Content-Type': 'application/json' },
|
7 |
body: JSON.stringify(body)
|
8 |
+
}).then(res => {
|
9 |
+
if (!res.ok) {
|
10 |
+
return res.json().then(err => { throw err; });
|
11 |
+
}
|
12 |
+
return res.json();
|
13 |
+
});
|
14 |
}
|
15 |
|
16 |
+
|
17 |
function apiGet(path) {
|
18 |
return fetch(`${apiBase}${path}`)
|
19 |
.then(res => res.json());
|