Reputation: 19
So I have set my PORT environment variable, lets say to 5555(using on windows cmd -> set PORT = 5555), yet when I use: process.env.PORT, I only get undefined, ....
const express = require ('express');
const app = express();;
app.get('/',(req,res) => {
res.send('Welcome To Learn How Here');
});
app.get('/api/courses',(req,res) => {
res.send(["English for dujms","HTML","JavaScript"]);
})
const port = process.env.PORT; //-> cant see whats wrong here???
app.listen(port, () => console.log(`Listening on port ${port}...`));
Upvotes: 0
Views: 41
Reputation: 31815
Nothing wrong in your code, just remove the spaces when you set PORT=5555
Upvotes: 1