title: Node.js `request.get`: store body in variable
body: <p>I’m new to Node.js, and so sorry for what is probably a dumb question…</p>
  
  <p>Here’s my code:</p>
  
  <pre><code>#!/usr/bin/env coffee --bare
  
  #   3rd party
  request  = require('request')
  request.defaults({'encoding': 'utf8'})
  
  module.exports.fetchDepartments = fetchDepartments
  
  fetchDepartments = (url) -&gt;
      _body = ''
  
      getHandler = (error, response, body) -&gt; 
          util.debug "HTTP response code: #{response.statusCode}"
  
          if error
              util.error error
          else    
              _body = body
  
      request.get(url, getHandler)
      _body
  
  console.log fetchDepartments('https://ntst.umd.edu/soc/')
  </code></pre>
  
  <p>The console is printing the call to <code>util.debug()</code>, but it seems that <code>_body</code> remains an empty  string. </p>
  
  <p>…How can I store the HTML from the HTTP response?!?</p>