Saturday, June 16, 2018

JavaScript - Simulate POST request from JS Console

Below code simulates a POST request from a JavaScript console:

var xhr = new XMLHttpRequest();
xhr.open('POST','https://mathbostock.execute-api.us-east-1.amazonaws.com/dev/random-items');
xhr.onreadystatechange = function(event) {
  console.log(event.target.response);
}

xhr.send();


Practice at:
https://codepen.io

No comments:

Post a Comment