25 lines
647 B
HTML
Raw Normal View History

2019-11-27 11:20:52 +01:00
<!DOCTYPE html>
<html>
2019-11-27 11:44:54 +01:00
<head>
<title>go-wasm-http-server demo</title>
<script>
2021-01-22 15:28:37 +01:00
navigator.serviceWorker.register('sw.js')
2021-01-21 23:07:42 +01:00
2019-11-27 11:47:20 +01:00
async function hello() {
res = await fetch('api/hello', {
2019-11-27 11:44:54 +01:00
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ name: document.querySelector("#name").value })
2019-11-27 11:44:54 +01:00
})
2019-11-27 11:47:20 +01:00
const { message } = await res.json()
alert(message)
2019-11-27 11:44:54 +01:00
}
</script>
</head>
2019-11-27 11:20:52 +01:00
<body>
2021-01-22 00:42:01 +01:00
<label for="name">Name: </label><input id="name" value="World">
2019-11-27 11:50:23 +01:00
<button onclick="hello()">Hello</button>
2019-11-27 11:20:52 +01:00
</body>
</html>