I’m new to Node.js, and so sorry for what is probably a dumb question…</p>
Here’s my code:
#!/usr/bin/env coffee --bare
# 3rd party
request = require('request')
request.defaults({'encoding': 'utf8'})
module.exports.fetchDepartments = fetchDepartments
fetchDepartments = (url) ->
_body = ''
getHandler = (error, response, body) ->
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/')
The console is printing the call to util.debug()
, but it seems that _body
remains an empty string.
…How can I store the HTML from the HTTP response?!?