1
0
mirror of https://github.com/actix/actix-website synced 2024-11-27 18:12:57 +01:00
actix-website/examples/powerful-extractors/static/form.html

44 lines
955 B
HTML
Raw Normal View History

2023-11-01 16:32:44 +01:00
<!DOCTYPE htmtl>
<html>
<head>
2023-11-01 16:32:44 +01:00
<meta charset="utf-8" />
<title>Forms</title>
</head>
<body>
<h3>Submit Json</h3>
<button onclick="submitJson()">Submit</button>
<script>
let payload = {
timestamp: 12345,
kind: "this is a kind",
2023-11-01 16:32:44 +01:00
tags: ["tag1", "tag2", "tag3"],
};
function submitJson() {
2023-11-01 16:32:44 +01:00
fetch("http://localhost:8080/event", {
method: "POST",
headers: {
2023-11-01 16:32:44 +01:00
Accept: "application/json",
"Content-Type": "application/json",
},
2023-11-01 16:32:44 +01:00
body: JSON.stringify(payload),
})
.then(function (res) {
return res.json();
})
.then(function (data) {
let expected = {
...payload,
2023-11-01 16:32:44 +01:00
id: 1,
};
console.log("expected: ", expected);
console.log("received: ", data);
});
}
</script>
</body>
</html>