JSFiddle - React, Tailwind, and code Playground
JavaScript
var json = {
json: JSON.stringify({
a: 1,
b: 2
}),
delay: 5
};
fetch('/echo/json/', {
method: 'post',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: json
})
.then(function (data) {
console.log('Request succeeded with JSON response', data);
})
.catch(function (error) {
console.log('Request failed', error);
});