title: Error connecting to MongoDB
body: <p>I have a small problem. I am trying to perform a simple operation but I keep on getting the same error, I am running out of ideas and I couldn't find anything in the internet...</p>
  
  <p>The portion of code causing the error is the following:</p>
  
  <pre><code>response.write(readDB(no));   // &lt;= this line
  response.end();
  </code></pre>
  
  <p>The readDB function is here:</p>
  
  <pre><code>function readDB(gene){
      console.log("test43");
      MongoClient.connect(url, function(err, db) {
    if(!err) {
      console.log("We are connected");
      console.log("test44");
      var collection = db.collection('links');
      var ans=  collection.find( { generated: gene}, {original:1, _id:0}, function(err, gg){
      console.log("test dat result:"+ans.original);
          console.log("acces to:"+ans.original);
          var rep
          rep.writeHead(200, {"Content-Type": "text/html"});
          rep.write("&lt;html&gt;");
          rep.write("&lt;head&gt;");
          rep.write("&lt;title&gt;Redirection&lt;/title&gt;");
          rep.write("&lt;meta http-equiv=\"refresh\" content=\"5\"; URL=\""+ans.original+"\"&gt;");
          rep.write("&lt;script type=\"text/javascript\"&gt;window.location.href = \""+ans.original+"\"&lt;/script&gt;");
          rep.write("&lt;/head&gt;");
          rep.write("&lt;body&gt;Redirection...");
          rep.write("&lt;/body&gt;");
          rep.write("&lt;/html&gt;");
          return rep;
    })
    }
    if(err){
      //console.log(err)
    }
    } )};
  </code></pre>
  
  <p>I know the code is not great, but still...
  The message "test43" is shown in my console, and after that I keep getting:</p>
  
  <pre><code>_http_outgoing.js:436
      throw new TypeError('first argument must be a string or Buffer');
      ^
  
  TypeError: first argument must be a string or Buffer
  </code></pre>
  
  <p>If someone could tell me what I am doing wrong it would be great !</p>
  
  <p>Thanks !</p>