Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
'use strict';
const http = require('https');
// Forward the button press onto our Heroku app
// as a POST request with a JSON body.
exports.handler = (event, context, callback) => {
const params = {
serialNumber: event.serialNumber,
event: event
};
const postData = JSON.stringify(params);
const req = http.request({
hostname: 'my-app-name.herokuapp.com',
port: 443,
path: '/button-presses',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(postData)
}
}, (res) => {
res.on('end', function() {
context.done(null);
});
})
req.write(postData);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.