Created
January 14, 2020 16:01
-
-
Save bennycode/ccc5ff6c23a80225839f19abf6507305 to your computer and use it in GitHub Desktop.
Hacky absence.io API example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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