Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PubNub Time Series AI w/ Falkonry BLOCK
function process(request) {
const xhr = require('xhr');
const token = 'YOUR_FALKONRY_API_TOKEN';
const webhookUrl = 'https://sandbox.falkonry.ai/webhook/YOUR_FALKONRY_WEBHOOK';
try {
request.message.time = new Date().getTime();
var params = {
method: 'POST',
headers: {
Authorization: 'Token ' + token,
Accept: 'application/json',
'Content-Type': 'application/json'
},
body: request.message
};
return xhr.fetch(webhookUrl, params).then(function (r) {
console.log(r);
return request.ok();
});
} catch (e) {
console.error('Uncaught exception:', e);
return request.ok();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment