Skip to content

Instantly share code, notes, and snippets.

@hash-bang
Created December 21, 2014 06:40
Show Gist options
  • Save hash-bang/f897f72fa8048ebb315d to your computer and use it in GitHub Desktop.
Save hash-bang/f897f72fa8048ebb315d to your computer and use it in GitHub Desktop.
Exec() to Request.Post()
var exec = require('child_process').exec;
var request = require('request');
exec('echo hello world', function(err, stdout, stderr) {
request.post({
method: 'POST',
url: 'http://localhost/post/this/somewhere',
formData: {
myFile: {
value: stdout,
options: {
filename: 'myfile.xml',
contentType: 'text/plain'
}
}
}
})
.on('response', function(res) {
console.log("DONE", res);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment