Skip to content

Instantly share code, notes, and snippets.

@Naramsim
Created May 18, 2016 06:23
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 Naramsim/32f7b9d7fe7e2a1acaa847415e7e60ad to your computer and use it in GitHub Desktop.
Save Naramsim/32f7b9d7fe7e2a1acaa847415e7e60ad to your computer and use it in GitHub Desktop.
var to_send = {}
to_send.title = "title";
to_send.content = "content";
to_send.author = "aut";
to_send.language = "css";
to_send = JSON.stringify(to_send);
var request = new XMLHttpRequest();
request.open('POST', 'http://localhost:3000/api/v1/new', true);
request.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
request.onreadystatechange = function () {
if (request.readyState == 4 && request.status == 200) {
var json = JSON.parse(request.responseText);
console.log(json);
}
}
request.send(to_send);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment