title: Node.js res.setheader is not a function at _respond
body: <p>I am getting the following error when making helper functions for node.js.  When I had it not in a helpersFunction.js it was working just fine.  How should one properly setup helper functions in Node.js?</p>
  
  <blockquote>
    <p>TypeError: res.setheader is not a function
        at _respond (/Users/camdixon/Sites/node/node_api2/helperFunctions.js:8:7)
        at Object.module.exports.success (/Users/camdixon/Sites/node/node_api2/helperFunctions.js:15:3)
        at /Users/camdixon/Sites/node/node_api2/routes.js:14:13
        at Layer.handle [as handle_request] (/Users/camdixon/Sites/node/node_api2/node_modules/express/lib/router/layer.js:95:5)
        at next (/Users/camdixon/Sites/node/node_api2/node_modules/express/lib/router/route.js:137:13)</p>
  </blockquote>
  
  <p>helperFunctions.js file</p>
  
  <pre><code>function _respond(res, next, status, data, http_code) {
    var response = {
      'status': status,
      'data': data
    };
  
    res.setheader('content-type', 'application/json');
    res.writeHead(http_code);
    res.end(JSON.stringify(response));
    return next();
  }
  
  module.exports.success = function(res, next, data) {
    _respond(res, next, 'OK', data, 200);
  }
  
  module.exports.failure = function(res, next, data, http_code) {
    _respond(res, next, 'Error', data, http_code);
  }
  </code></pre>
  
  <p>My Routes.js file</p>
  
  <pre><code>var helpers = require('./helperFunctions.js');
  
  module.exports = function (app) {
  
    var list = {}
  
    app.post('/list/create', function(req, res, next) {
      list = req.body.email_address;
      console.log(list);
  
      helpers.success(res, next, list);
    });
  
  };
  </code></pre>