dasunpubudumal
8/9/2017 - 7:30 AM

app.js


function request(something){
    console.log("Client requested: ", something);   //This is the request.

    processAndSearch(function() {   //Now it will respond.
        console.log("Server responded to the request of: ", something);
    });
};

function processAndSearch(response){
    setTimeout(response, 3000); //Here I've assumed that processing and searching
    //for data takes only 3 seconds.
}

//Lets request the data now.

request("Eggs");
request("Butter");
request("Vanilla Extract");
request("Flour");
request("Sugar");