Skip to content

Instantly share code, notes, and snippets.

@gnujoow
Created March 9, 2017 01:23
Show Gist options
  • Save gnujoow/85e205a8bc04efdc406c6723974eca4e to your computer and use it in GitHub Desktop.
Save gnujoow/85e205a8bc04efdc406c6723974eca4e to your computer and use it in GitHub Desktop.
inter.js
var data = JSON.stringify({
"from": {
"type": "user",
"id": "gnujoow.kim@gmail.com"
},
"body": "Hey"
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.intercom.io/messages");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("cache-control", "no-cache");
xhr.send(data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment