-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapiform.html
26 lines (23 loc) · 1017 Bytes
/
apiform.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<!DOCTYPE html>
<script src="main.js"></script>
<link rel="stylesheet" href="ui/forms.css">
<style>
@font-face { font-family: Nunito; src: url(ui/nunito.woff); }
@font-face { font-family: gfx; src: url(ui/gfx.woff); }
html { font: 16px Nunito, sans-serif; background: #EEE; }
textarea { resize: vertical; width: 100%; height: 8em; }
output { white-space: pre-line; }
#tgt, output, textarea { font: 20px monospace; }
</style>
<input id="tgt" placeholder="Požadavek..."><br>
<textarea id="get" placeholder="GET data as JSON..."></textarea><br>
<textarea id="post" placeholder="POST data as JSON..."></textarea><br>
<button onclick="test()">Odešli</button><br><br>
<output id="output"></output>
<script>
const test = _ =>
new Promise(Y => Y({get: JSON.parse(get.value||"{}"), post: JSON.parse(post.value||"{}")}))
.then(data => API(tgt.value + getData(data.get), post.value && postData(data.post)))
.then(data => output.innerHTML = data.response)
.catch(error => output.innerHTML = error);
</script>