Created
September 7, 2017 01:33
-
-
Save rajat1saxena/86856a9c00344d7950b98b3933929a6d to your computer and use it in GitHub Desktop.
Send a XHR request
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 xhr = new XMLHttpRequest(); | |
xhr.responseType = 'json'; | |
xhr.open("POST", "/graphql"); | |
xhr.setRequestHeader("Content-Type", "application/json"); | |
xhr.setRequestHeader("Accept", "application/json"); | |
xhr.onload = function () { | |
console.log('data returned:', xhr.response); | |
} | |
xhr.send(JSON.stringify({query: "{ hello }"})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment