title: Accessing Cloudant using nodejs nano
body: <p>Is there a gist which I can follow to use to connect to cloudant using nano / nodejs. Or, is there any other library which I can use to connect from nodejs to cloudant.  Here is the error I encounter, when i try to connect.</p>
  
  <pre><code>  description: 'one of _writer, _creator is required for this request',
  </code></pre>
  
  <p>Here is how my code looks</p>
  
  <pre><code>// require nano, point it at cloudant's root
  var config = require('config');
  var nano = require('nano')({url: config.cloudant.url})
      , username = config.cloudant.username
      , userpass = config.cloudant.password
      , cookies = {}
      , callback = console.log // this would normally be some callback
  
    ;
  
  
  nano.auth(username, userpass, function (err, body, headers) {
      if (err) {
          return callback(err);
      }
  
      if (headers &amp;&amp; headers['set-cookie']) {
          cookies['user'] = headers['set-cookie'];
      }
  
      callback(null, "it worked");
  });
  
  
  
  
  var db = require('nano')({
      'url': config.cloudant.url + '/' + config.cloudant.database,
      'cookie': cookies['user']
  });
  </code></pre>
  
  <p>After this, when i try to connect - i get the error</p>
  
  <pre><code>var db = require('nano')({
      'url': config.cloudant.url + '/' + config.cloudant.database,
      'cookie': cookies['user']
  });
  
  var doc = {"hello": "world"};
  
  db.insert(doc, function (err, body, headers) {
      if (err) {
          return callback(err);
      }
  
      // change the cookie if couchdb tells us to
      if (headers &amp;&amp; headers['set-cookie']) {
          cookies['user'] = headers['set-cookie'];
      }
  
      callback(null, "it worked");
  });
  </code></pre>