var customXMLHttpRequest = (function (jwtoken) {
function getXMLHttpRequest(method, url, async){
var xmlHttpRequest = new XMLHttpRequest();
xmlHttpRequest.open(method, url, async);
xmlHttpRequest.setRequestHeader('Authorization', 'Bearer ' + jwtoken);
return xmlHttpRequest;
}
return getXMLHttpRequest;
})('Your token');
var params = 'name=intro_home&status=true';
var xhttp = new XMLHttpRequest();
xhttp.open("POST", process.env.API_URL + 'intro/save', true);
xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhttp.setRequestHeader('Authorization', localStorage.getItem('auth._token.laravelJWT'));
xhttp.onreadystatechange = function () {//Call a function when the state changes.
if (xhttp.readyState == 4 && xhttp.status == 200) {
alert('ok');
}
}
xhttp.send(params);