Last active
February 10, 2019 08:50
-
-
Save mateothegreat/320d6f68f9665448553139854bfbfb11 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
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