Skip to content

Instantly share code, notes, and snippets.

@mattlockyer
Last active April 24, 2019 17:55
Show Gist options
  • Save mattlockyer/6e1dff34962b0c47e84c3eca414e266e to your computer and use it in GitHub Desktop.
Save mattlockyer/6e1dff34962b0c47e84c3eca414e266e to your computer and use it in GitHub Desktop.
JSON POST from console
fetch('http://localhost:8080/test', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({name:'matt', number:34}),
// optional
// mode: "cors", // no-cors, cors, *same-origin
// cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached
// credentials: "same-origin", // include, *same-origin, omit
// redirect: "follow", // manual, *follow, error
// referrer: "no-referrer", // no-referrer, *client
}).then((res) => res.json()).then((res) => console.log(res))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment