Nicolas Lepage 04f6573b78
♻️
2021-01-25 11:07:52 +01:00

30 lines
683 B
HTML

<!DOCTYPE html>
<html>
<head>
<title>go-wasm-http-server hello demo</title>
<script>
navigator.serviceWorker.register('sw.js')
async function hello() {
const name = document.querySelector("#name").value
const res = await fetch('api/hello', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ name })
})
const { message } = await res.json()
alert(message)
}
</script>
</head>
<body>
<label for="name">Name: </label><input id="name" value="World">
<button onclick="hello()">Hello</button>
</body>
</html>