Skip to content

Instantly share code, notes, and snippets.

@taosx
Last active June 24, 2016 00:41
Show Gist options
  • Save taosx/7098ac942e003c78cdf1224b12686335 to your computer and use it in GitHub Desktop.
Save taosx/7098ac942e003c78cdf1224b12686335 to your computer and use it in GitHub Desktop.
Use fetch to HTTP json
var payload = {
to: nameTo,
by: nameBy
};
fetch('/api/love/declare', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(payload)
}).then(res => {
// Do something important with the response
console.log(res);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment