Hi,
I am wondering why my server side code only outputs "Hi ${port}" on console without (1) showing the actual port number or (2) opening up the "locolhost:5000" web page. My command is "npm start server." The screenshots of (1) the code and the (2) scripts part of the package.json file are attached. Thanks!
https://dev-to-uploads.s3.amazonaws.com/i/fqccj2yqjogkszwzkjp5.png
https://dev-to-uploads.s3.amazonaws.com/i/w90w553emwra9deb7y8k.png
Top comments (7)
Because your "Hi ${port}" is a regular string which doesn't allow to paste variables there. You meant to use a template string.
Thanks! Besides, do you know from this code why locolhost:5000 did not load though?
The server handles only "/api/sessions" route, not the "/" you are trying to access by opening localhost:5000. You should add the handler for that too.
As others mentioned, use
backticsin order to allow string interpolation.And, regarding your server, it's indeed listening, but, it'll only respond to requests when you hit
localhost:5000/api/sessionssince you don't have a default handler for/route.Thanks!
use ` back ticks instead of ' single quotes in console.log .
Thanks! Besides, do you know from this code why locolhost:5000 did not load though?