Add Createsession, joinsession to ui

This commit is contained in:
Dominic Zimmer 2020-04-17 01:48:38 +02:00
parent db3d21a1fe
commit 43a2a40207

21
ui.html
View File

@ -9,14 +9,27 @@
<body> <body>
this is the UI this is the UI
<button id="test_api">Test API</button> <!--<button id="test_api">Test API</button>-->
<button id="btn_create_session">Create session</button>
<br><br><br>
<input id="join_session_id" type="text" placeholder="Enter session id" />
<button id="btn_join_session">Create session</button>
<script src="/static/renderer.js"></script> <script src="/static/renderer.js"></script>
<script> <script>
document.getElementById("test_api").onclick = async function (e) { document.getElementById("btn_create_session").onclick = async function (e) {
let data = {foo: 'bar'}; let data = {};
await fetch('api', { await fetch('api/create_session', {
method: 'POST',
body: JSON.stringify(data),
})
};
document.getElementById("btn_join_session").onclick = async function (e) {
let text = document.getElementById("join_session_id").text
let data = {"sessionid": text};
await fetch('api/join_session', {
method: 'POST', method: 'POST',
body: JSON.stringify(data), body: JSON.stringify(data),
}) })