Skip to content

Instantly share code, notes, and snippets.

@bennycode
Created January 14, 2020 16:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bennycode/ccc5ff6c23a80225839f19abf6507305 to your computer and use it in GitHub Desktop.
Save bennycode/ccc5ff6c23a80225839f19abf6507305 to your computer and use it in GitHub Desktop.
Hacky absence.io API example
const Hawk = require('@hapi/hawk');
const request = require('request');
const API_KEY = 'KEY';
const API_KEY_ID = 'ID';
const credentials = {
id: API_KEY_ID,
key: API_KEY,
algorithm: 'sha256'
};
const url = 'https://app.absence.io/api/v2/absences';
const body = {
skip: 0,
limit: 50,
filter:
{
start: {'$lte': '2020-01-14T00:00:00.000Z'},
end: {'$gte': '2020-01-14T00:00:00.000Z'}
},
relations: ['assignedToId', 'reasonId', 'approverId']
};
const options = {
body,
url,
method: 'POST',
headers: {
Authorization: {}
},
json: true
};
const {header} = Hawk.client.header(options.url, options.method, {credentials: credentials});
options.headers.Authorization = header;
request(options, (error, response, data) => {
console.log('Response', data);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment