public/http-utils.js
// Request body is an object which will be converted to json
Request body is an object which will be converted to json
Request body is an object which will be converted to json
function httpPostAsync(theUrl, requestBody, callback) {
    var xhr = new XMLHttpRequest();
    xhr.open("POST", theUrl, true);
    xhr.setRequestHeader("Content-Type", "application/json");
    xhr.onreadystatechange = xhr.onreadystatechange = function () {
        if (xhr.readyState === 4 && xhr.status === 200) {
            var json = JSON.parse(xhr.responseText);
            callback(json);
        }
    };;
    let jsonBody = JSON.stringify(requestBody);
    xhr.send(jsonBody);
}
function httpPostAsync ( theUrl , requestBody , callback ) { var xhr = new XMLHttpRequest ( ) ; xhr . open ( "POST" , theUrl , true ) ; xhr . setRequestHeader ( "Content-Type" , "application/json" ) ; xhr . onreadystatechange = xhr . onreadystatechange = function ( ) { if ( xhr . readyState === 4 && xhr . status === 200 ) { var json = JSON . parse ( xhr . responseText ) ; callback ( json ) ; } } ; ; let jsonBody = JSON . stringify ( requestBody ) ; xhr . send ( jsonBody ) ; }
Request body is an object which will be converted to json
Request body is an object which will be converted to json