title: getaddrinfo ENOTFOUND with Node.js http.request()
body: <p>I'm trying to follow the badgekit tutorial here <a href="https://github.com/mozilla/badgekit-api/wiki/Using-BadgeKit-API#references" rel="nofollow">https://github.com/mozilla/badgekit-api/wiki/Using-BadgeKit-API#references</a></p>
  
  <p>However, the error I'm getting is a node error with my syntax (I think). This is what I have in the file RetrieveBadgeData.js</p>
  
  <pre><code>var http = require("http");
  var jws = require('jws');
  
  var claimData = {
      header: { typ: 'JWT', alg: 'HS256' },
      payload: {
          key: 'mastersecret',
          exp: Date.now() + (1000 * 60),
          method: 'GET',
          path: '/systems'
      },
      secret: 'mastersecret'
  };
  var requestOptions = {
      host: 'http://192.168.1.59:8080',
      path: '/systems',
      method: 'GET',
      headers: { 'Authorization': 'JWT token="' + jws.sign(claimData) + '"' }
  };
  
  var apiRequest = http.request(requestOptions, function (apiResult) {
      apiResult.on('data', function (badgeData) {
          //process badgeData
  
      });
  });
  </code></pre>
  
  <p>If I browse to 192.168.1.59:8080 I get what you're supposed to get back if the node API is running
  But, when I run node RetrieveBadgeData.js (executing the code above) I get this error.</p>
  
  <pre><code>events.js:72
      throw er; // unhandled 'error' event
            ^
  Error: getaddrinfo ENOTFOUND
      at errnoException (dns.js:37:11)
      at Object.onanswer [as oncomplete] (dns.js:124:16)
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p><strong>Edit</strong>
  I've also tried this, which gives me the same error</p>
  
  <pre><code>var requestOptions = {
      hostname: 'http://192.168.1.59'
      , port: 8080
      , path: '/systems/badgekit/badges'
      , method: 'GET'
      , headers: { 'Authorization': 'JWT token="' + jws.sign(claimData) + '"' }
  };
  </code></pre>