get started on submit page
This commit is contained in:
parent
bfbcc173f8
commit
2e3606f1b6
1 changed files with 27 additions and 2 deletions
|
@ -1,2 +1,27 @@
|
||||||
<h1>Welcome to SvelteKit</h1>
|
<script lang="ts">
|
||||||
<p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p>
|
let code = "";
|
||||||
|
|
||||||
|
async function submitCode() {
|
||||||
|
console.log("click");
|
||||||
|
let response = await fetch("/api/submit_bot", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
"code": code,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw Error(response.statusText);
|
||||||
|
}
|
||||||
|
|
||||||
|
let responseData = await response.json()
|
||||||
|
console.log(responseData);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<h1>Planetwars</h1>
|
||||||
|
<textarea bind:value={code} />
|
||||||
|
<button on:click={submitCode}>Submit</button>
|
Loading…
Reference in a new issue