JSFiddle - React, Tailwind, and code Playground
by Ishank Dubey
JavaScript
XMLHttpRequest.prototype.oldSend =
XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function(arg){
this.setRequestHeader("Authorization","Bearer "+"test");
this.oldSend(arg);
}
var xhr = new XMLHttpRequest();
xhr.open("POST", '/server', true);
//Send the proper header information along with the request
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {//Call a function when the state changes.
alert('ids');
if(xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
// Request finished. Do processing here.
}
}
xhr.send();