2019-06-13 01:23:51 +02:00
|
|
|
<!doctype htmtl>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta charset=utf-8>
|
|
|
|
<title>Forms</title>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
<h3>Submit Json</h3>
|
|
|
|
|
|
|
|
<button onclick="submitJson()">Submit</button>
|
|
|
|
|
|
|
|
<script>
|
2019-06-13 05:25:00 +02:00
|
|
|
let payload = {
|
|
|
|
timestamp: 12345,
|
|
|
|
kind: "this is a kind",
|
|
|
|
tags: ['tag1', 'tag2', 'tag3'],
|
|
|
|
}
|
|
|
|
|
2019-06-13 01:23:51 +02:00
|
|
|
function submitJson() {
|
|
|
|
fetch('http://localhost:8000/event', {
|
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'Accept': 'application/json',
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
},
|
2019-06-13 05:25:00 +02:00
|
|
|
body: JSON.stringify(payload)
|
2019-06-13 01:23:51 +02:00
|
|
|
})
|
|
|
|
.then(function (res) {
|
2019-06-13 05:25:00 +02:00
|
|
|
return res.json();
|
2019-06-13 01:23:51 +02:00
|
|
|
})
|
|
|
|
.then(function (data) {
|
2019-06-13 05:25:00 +02:00
|
|
|
let expected = {
|
|
|
|
...payload,
|
|
|
|
id: 1
|
|
|
|
};
|
|
|
|
console.log("expected: ", expected);
|
|
|
|
console.log("received: ", data);
|
2019-06-13 01:23:51 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|