Skip to content

Instantly share code, notes, and snippets.

@mateothegreat mateothegreat/request.js
Last active Feb 10, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.