1
0
mirror of https://github.com/actix/actix-website synced 2025-06-30 00:34:58 +02:00

Updates front-page flexible-responders to v1.0

This commit is contained in:
Cameron Dershem
2019-06-12 23:25:00 -04:00
parent 118286afb1
commit d2a2fc6979
4 changed files with 42 additions and 9 deletions

View File

@ -11,6 +11,12 @@
<button onclick="submitJson()">Submit</button>
<script>
let payload = {
timestamp: 12345,
kind: "this is a kind",
tags: ['tag1', 'tag2', 'tag3'],
}
function submitJson() {
fetch('http://localhost:8000/event', {
method: 'POST',
@ -18,17 +24,18 @@
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
timestamp: 12345,
kind: "this is a kind",
tags: ['tag1', 'tag2', 'tag3'],
})
body: JSON.stringify(payload)
})
.then(function (res) {
return res.text();
return res.json();
})
.then(function (data) {
console.log(data);
let expected = {
...payload,
id: 1
};
console.log("expected: ", expected);
console.log("received: ", data);
});
}
</script>