A simple question. I am trying to update a variable inside a function passed to another function. Of course, it will not work like this, but what is the workaround for responseText to be updated inside http.request
var responseText;
var req = http.request(options, function(res) {
var status = res.statusCode;
if (status == 400) {
responseText = "failed";
} else if (status == 200) {
responseText = "success";
}
});
req.write(post_data);
req.end();
console.log(responseText)
What are the solutions to resolve this.? Thanks