title: Node.js: TypeError: object is not a function
body: <p>I have a weird error:</p>
  
  <pre><code>var http = require("http");
  var request = require("request");
  
  http.createServer(function(request, response) {
      response.writeHead(200, {"Content-Type": "text/plain"});
  
      request('http://www.google.com', function (error, response, body) {
          if (!error &amp;&amp; response.statusCode == 200) {
              console.log(body) // Print the google web page.
          }
      });
      response.end();
  }).listen(8888);
  </code></pre>
  
  <p>The idea is for it to listen as a webserver, and then do a request.
  But this is what I get as error:</p>
  
  <pre><code>    request('http://www.google.com', function (error, response, body) {
      ^
  TypeError: object is not a function
      at Server.&lt;anonymous&gt; (/Users/oplgkim/Desktop/iformtest/j.js:8:2)
      at Server.EventEmitter.emit (events.js:98:17)
      at HTTPParser.parser.onIncoming (http.js:2056:12)
      at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:120:23)
      at Socket.socket.ondata (http.js:1946:22)
      at TCP.onread (net.js:525:27)
  </code></pre>
  
  <p>What am I doing wrong?
  I installed request, so that's not it :)</p>