Created
June 29, 2017 05:11
-
-
Save kellysutton/5523523d25583471ed041b054100b41a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
'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