I installed the npm module upper-case
as following
npm install upper-case
Thereafter, I executed the following code in node.
let http = require('http');
let uc = require('upper-case');
http.createServer( (req, res) => {
res.writeHead(200, {'Content-Type': 'text/html'});
res.write(uc("Hello World!"));
res.end();
}).listen(8080);
However, I can not get it to work. I get the following response.
TypeError: uc is not a function
at Server.http.createServer (/.../foo.js:34:13)
at Server.emit (events.js:189:13)
at parserOnIncoming (_http_server.js:676:12)
at HTTPParser.parserOnHeadersComplete (_http_common.js:109:17)
Why? What's going on!?
Really strange... But the following seems to work for some reason. I couldn't find this anywhere in the original npm module docs. Can anybody explain why this works?
let http = require('http');
let uc = require('upper-case');
http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/html' });
res.write(uc.upperCase("Hello World!"));
res.end();
}).listen(8080);