Skip to content

Instantly share code, notes, and snippets.

@georgebrata
Created November 22, 2018 20:01
Show Gist options
  • Save georgebrata/3d02afe1ea975690c7bcb1c146970938 to your computer and use it in GitHub Desktop.
Save georgebrata/3d02afe1ea975690c7bcb1c146970938 to your computer and use it in GitHub Desktop.
POST request example using fetch
let URL = "https://example.com/api";
fetch(URL, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
body: JSON.stringify({query: "{ hello }"})
})
.then(r => r.json())
.then(data => console.log('data returned:', data));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment