title: npm request with headers and auth
body: <p>I am trying to access an API using "request" npm. This API requires header "content-type" and a basic authentication. here is what I've done so far. </p>
  
  <pre><code>var request = require('request');
  var options = {
    url: 'https://XXX/index.php?/api/V2/get_case/2',
    headers: {
      'content-type': 'application/json'
    },
  
  };
  request.get(options, function(error, response, body){
  console.log(body);
  }
  
  ).auth("dummyemail@abc.com","password",false);
  </code></pre>
  
  <p>upon executing this using Node , I am getting an error that says invalid username and password. I've validated the same API, authentication and header using CURL with the command below and it gave an expected HTTP response. </p>
  
  <p>curl -X GET -H "content-type: application/json"   -u dummyemail@abc.com:password "<a href="https://XXX/index.php?/api/V2/get_case/2" rel="noreferrer">https://XXX/index.php?/api/V2/get_case/2</a>"</p>
  
  <p>Please suggest the right way to code request with auth and header.</p>
  
  <hr>
  
  <p>Here is my update code</p>
  
  <pre><code>var auth = new Buffer("dummy@gmail.com" + ':' + "password").toString('base64');
       var req = {
                      host: 'https://URL',
                      path: 'index.php?/api/v2/get_case/2',
                      method: 'GET',
                      headers: {
                          Authorization: 'Basic ' + auth,
                          'Content-Type': 'application/json'
                                }
                  };
      request(req,callback);
      function callback(error, response, body) {
        console.log(body);
      }
  </code></pre>
  
  <p>I am seeing 'undefined' in my console. can you help me here?</p>