1const https = require('https')
2const options = {
3 hostname: 'whatever.com',
4 port: 443,
5 path: '/todos',
6 method: 'GET'
7}
8
9const req = https.request(options, res => {
10 console.log(`statusCode: ${res.statusCode}`)
11
12 res.on('data', d => {
13 process.stdout.write(d)
14 })
15})
16
17req.on('error', error => {
18 console.error(error)
19})
20
21req.end()
1
2//HTTP MODULE NODE.JS
3var http = require('http');
4var server = http.createServer(function(req, res){
5 //write code here
6});
7server.listen(5000);
1var http = require('http');
2
3//create a server object:
4http.createServer(function (req, res) {
5 res.write('Hello World!'); //write a response to the client
6 res.end(); //end the response
7}).listen(8080); //the server object listens on port 8080