Skip to content

Instantly share code, notes, and snippets.

@rajat1saxena
Created September 7, 2017 01:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rajat1saxena/86856a9c00344d7950b98b3933929a6d to your computer and use it in GitHub Desktop.
Save rajat1saxena/86856a9c00344d7950b98b3933929a6d to your computer and use it in GitHub Desktop.
Send a XHR request
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