title: Set variable inside a function passed to another function
body: <p>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</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>What are the solutions to resolve this.?
  Thanks</p>