Skip to content

Instantly share code, notes, and snippets.

@mateothegreat
Last active February 10, 2019 08:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mateothegreat/320d6f68f9665448553139854bfbfb11 to your computer and use it in GitHub Desktop.
Save mateothegreat/320d6f68f9665448553139854bfbfb11 to your computer and use it in GitHub Desktop.
const https = require('https')
const data = JSON.stringify({
someProp: 'some value'
});
const options = {
hostname: 'google.com',
port: 443,
path: '/stuff',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': data.length
}
}
const req = https.request(options, (res) => {
console.log(`statusCode: ${res.statusCode}`)
res.on('data', (d) => {
process.stdout.write(d);
});
});
req.on('error', (error) => {
console.error(error);
});
req.write(data);
req.end();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment