Skip to content

Instantly share code, notes, and snippets.

@jacobg
Last active December 17, 2015 22:49
Show Gist options
  • Save jacobg/5684875 to your computer and use it in GitHub Desktop.
Save jacobg/5684875 to your computer and use it in GitHub Desktop.
Fareclock API sample for NodeJS
var Https = require('https'),
Querystring = require('querystring'),
result = [],
token = '{{ MY API KEY }}',
params = {
'from': '2013-05-31',
'to': '2013-05-31',
//'paylocation': 0,
//'clocklocation': 0,
//'employee': 0,
//'department': 0,
//'status': 'all'
},
options = {
host: 'www.fareclock.com',
path: '/api/punches/?' + Querystring.stringify(params),
headers: {
Authorization: 'Token ' + token
}
};
Https.get(options, function(res) {
//console.log('STATUS: ' + res.statusCode);
//console.log('HEADERS: ' + JSON.stringify(res.headers));
res.on('data', function (chunk) {
//console.log('BODY: ' + chunk);
result.push(chunk);
});
res.on('end', function(){
console.log("Result: " + result.join());
//
// I have my result. Now do whatever I want to do with it.
//
});
}).on('error', function(res) {
console.log('ERROR: ' + e.message);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment