Last active
June 24, 2016 00:41
-
-
Save taosx/7098ac942e003c78cdf1224b12686335 to your computer and use it in GitHub Desktop.
Use fetch to HTTP json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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