I'm trying to follow the badgekit tutorial here https://github.com/mozilla/badgekit-api/wiki/Using-BadgeKit-API#references
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
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
});
});
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.
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)
Any ideas?
Edit I've also tried this, which gives me the same error
var requestOptions = {
hostname: 'http://192.168.1.59'
, port: 8080
, path: '/systems/badgekit/badges'
, method: 'GET'
, headers: { 'Authorization': 'JWT token="' + jws.sign(claimData) + '"' }
};