app/js/communication_layer.js
// Makes POST request at endpoint at path
Makes POST request at endpoint at path
Makes POST request at endpoint at path
function postRequest(path, context, json_obj) {
    console.log("Post Request called: ", path, context, json_obj);
    var start = performance.now();
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function () {
        if (this.readyState == 4 && this.status == 200) {
            var end = performance.now()
            console.log(`Index time: ${end-start}`);
            handleResponse(xhttp.responseText, context);
        }
    };
    xhttp.open("POST", "http://localhost:5000/" + path, true);
    xhttp.setRequestHeader('Content-Type', 'application/json');
    xhttp.send(JSON.stringify(json_obj));
}
function postRequest ( path , context , json_obj ) { console . log ( "Post Request called: " , path , context , json_obj ) ; var start = performance . now ( ) ; var xhttp = new XMLHttpRequest ( ) ; xhttp . onreadystatechange = function ( ) { if ( this . readyState == 4 && this . status == 200 ) { var end = performance . now ( ) console . log ( ` ${ end - start } ` ) ; handleResponse ( xhttp . responseText , context ) ; } } ; xhttp . open ( "POST" , "http://localhost:5000/" + path , true ) ; xhttp . setRequestHeader ( 'Content-Type' , 'application/json' ) ; xhttp . send ( JSON . stringify ( json_obj ) ) ; }
Makes POST request at endpoint at path
Makes POST request at endpoint at path
// For latency // Handles response