ciyidogan commited on
Commit
d917409
·
verified ·
1 Parent(s): 3f5b361

Create common.js

Browse files
Files changed (1) hide show
  1. static/common.js +18 -0
static/common.js ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const apiBase = '';
2
+
3
+ function apiPost(path, body) {
4
+ return fetch(`${apiBase}${path}`, {
5
+ method: 'POST',
6
+ headers: { 'Content-Type': 'application/json' },
7
+ body: JSON.stringify(body)
8
+ }).then(res => res.json());
9
+ }
10
+
11
+ function apiGet(path) {
12
+ return fetch(`${apiBase}${path}`)
13
+ .then(res => res.json());
14
+ }
15
+
16
+ function showResult(id, data) {
17
+ document.getElementById(id).innerText = data.message || JSON.stringify(data, null, 2);
18
+ }