Just started playing with Node.js and after seeing a few examples I see that usually the Content-Type is set before returning some content.
Usually somethin
Of course not, if you are playing with NodeJs. But to make a maintainable code with different modules, large and API pages you should have 'Content-Type' in your server definition.
const http = require('http');
const host_name = 'localhost';
const port_number = '3000';
const server = http.createServer((erq, res) => {
res.statusCode = 200;
// res.setHeader('Content-Type', 'text/html');
res.end(" Head Line
Line 2
Line 3");
});
server.listen(port_number, host_name, ()=> {
console.log(`Listening to http://${host_name}:${port_number}`);
});