Skip to content

Instantly share code, notes, and snippets.

@johnnyman727
Created June 4, 2014 18:44
Show Gist options
  • Save johnnyman727/879cd02cc9fa009a6e3b to your computer and use it in GitHub Desktop.
Save johnnyman727/879cd02cc9fa009a6e3b to your computer and use it in GitHub Desktop.
var tessel = require('tessel');
var https = require('https');
var querystring = require('querystring');
// Build the post string from an object
var post_data = querystring.stringify({
'accel-x' : '1.24353',
'accel-y': '-.543653',
'accel-z': '0.021234',
});
// An object of options to indicate where to post to
var post_options = {
host: '<HOST>.com',
port: '80',
path: '/<PATH>',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': post_data.length
}
};
// Set up the request
var post_req = https.request(post_options, function(res) {
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('Response: ' + chunk);
});
});
// post the data
post_req.write(post_data);
post_req.end();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment