JSFiddle - React, Tailwind, and code Playground
JavaScript
var json = {
json: JSON.stringify({
a: 1,
b: 2
}),
delay: 1
};
fetch('/echo/json/', {
method: 'post',
headers: {
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json'
},
body: 'json=' + encodeURI(JSON.stringify(json.json)) + '&delay=' + json.delay
})
.then(function (response) {
return response.json();
})
.then(function (result) {
alert(JSON.stringify(result));
})
.
catch (function (error) {
console.log('Request failed', error);
});