This is really a question around Javascript scope and functions so I apologise as I'm a newbie to JS!!
I have a snippet of javascript, that connects creates a HTTPClient connection to a REST service from Vertx - this all works fine no issues here.
My problem is that I need access to the "status" and "data" returned from the "client.request" outside of this call
// Create the HTTP Client
var client = vertx.createHttpClient().host(host).port(ssl_port).ssl(true);
var request = client.request("POST", "/api/en/v1.0/authentication/token/new" + "?login_id=" + login_id + "&api_key=" + api_key, function(resp) {
//console.log("Got a response: " + resp.statusCode());
resp.bodyHandler(function(body) {
// Parse the JSON string into a new object.
var response = JSON.parse(body);
console.log("status : " + response.status);
console.log("data : " + response.data);
})
});
request.end();
So in code down here I'd like to use/access "status" and "data". In another language I'd just return them as an object up the call stack.