blob: 6b1403429f7d552e300d3de4d356f1ab2ed2c7bb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
async function handle_fetch(promise) {
const result = await promise;
const json = await result.json();
if (!result.ok) {
throw json;
}
return json;
}
export function get(url) {
return handle_fetch(fetch(url));
}
export function post(url, body) {
return handle_fetch(fetch(url, {
method: 'POST',
body: JSON.stringify(body),
}));
}
|