Chapter 4,6: prettier updates and web framework samples
This commit is contained in:
@@ -1,28 +1,28 @@
|
||||
const https = require('https')
|
||||
const https = require("https");
|
||||
|
||||
// http.get('http://example.com', (res) => res.pipe(process.stdout))
|
||||
|
||||
const payload = `{
|
||||
"name": "Beth",
|
||||
"job": "Software Engineer"
|
||||
}`
|
||||
}`;
|
||||
|
||||
const opts = {
|
||||
method: 'POST',
|
||||
hostname: 'postman-echo.com',
|
||||
path: '/post',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Content-Length': Buffer.byteLength(payload)
|
||||
}
|
||||
}
|
||||
method: "POST",
|
||||
hostname: "postman-echo.com",
|
||||
path: "/post",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Content-Length": Buffer.byteLength(payload),
|
||||
},
|
||||
};
|
||||
|
||||
const req = https.request(opts, (res) => {
|
||||
process.stdout.write('Status Code: ' + res.statusCode + '\n')
|
||||
process.stdout.write('Body: ')
|
||||
res.pipe(process.stdout)
|
||||
})
|
||||
process.stdout.write("Status Code: " + res.statusCode + "\n");
|
||||
process.stdout.write("Body: ");
|
||||
res.pipe(process.stdout);
|
||||
});
|
||||
|
||||
req.on('error', (err) => console.error('Error: ', err))
|
||||
req.on("error", (err) => console.error("Error: ", err));
|
||||
|
||||
req.end(payload)
|
||||
req.end(payload);
|
||||
|
||||
Reference in New Issue
Block a user