Created
November 22, 2018 20:01
-
-
Save georgebrata/3d02afe1ea975690c7bcb1c146970938 to your computer and use it in GitHub Desktop.
POST request example using fetch
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
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