-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
30 lines (29 loc) · 877 Bytes
/
index.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
27
28
29
30
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>coderunner</title>
</head>
<body>
<textarea id="code"></textarea>
<button id="btn">run</button>
<script>
const btn = document.querySelector("#btn");
btn.addEventListener("click", () => {
const code = document.querySelector("#code").value;
console.log({code})
fetch("http://localhost:4000/api/v1/exec/js", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ code }),
})
.then((response) => response.json())
.then((result) => console.log(result))
.catch((error) => console.error("Error:", error));
});
</script>
</body>
</html>