title: How can I connect my mongodb with the NODEjs app on Bluemix?
body: <p>I have tried the below code for VCAP_SERVICES :</p>
  
  <pre><code>if (process.env.VCAP_SERVICES) {
        var env = JSON.parse(process.env.VCAP_SERVICES);
        if (env['mongodb-2.2']) {
          var mongo = env['mongodb-2.2'][0]['credentials'];
        }
      } else {
             var mongo = {
                "username" : "user1",
                "password" : "secret",
                "url" : "mongodb://user1:secret@localhost:27017/test"
       }
  }
  
  //With this as the connector
  var MongoClient = mongodb.MongoClient;
  var db= MongoClient.connect(mongo.url, function(err, db) {
    if(err) {
      console.log("failed to connect to the database");
    } else {
      console.log("connected to database");
    }
  </code></pre>
  
  <p>but it keeps throwing " TypeError : Cannot read property "url" of underfined "</p>
  
  <p>I have tried using monk as a connector giving : </p>
  
  <pre><code>var monk = require('monk');
   var db = monk(mongo.url);
  </code></pre>
  
  <p>This also throws the same error. I may be using the object mongo incorrectly.</p>