Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
pak yin chan
6,834 PointsWhat does "=>" do?
const http = require('http');
const hostname = '127.0.0.1';
const port = 1337;
http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello World\n');
}).listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
In the Nodejs doc the code to set up the server is different from the example in the video. I changed out the req and res to request and response, see below:
const http = require('http');
const port = 3000;
http.createServer((request, response) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello World\n');
}).listen(port, () => {
console.log("Server running at http://<url>/");
});
It's saying that the "() =>" after the port is an unexpected token. What went wrong?
Chyno Deluxe
16,936 PointsChyno Deluxe
16,936 Points//Fixed Code Presentation