I have this code currently:
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var sessionManager = require("./SessionRaterBL");
sessionManager.CreateTestData();
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
var port = process.env.PORT || 8080;
var router = express.Router();
var sessionRouter = express.Router();
router.get('/', function(req, res) {
res.json({ message: 'API Session Rater Backend' });
});
sessionRouter.get("/",function(req,res){
res.json(sessionManager.GetSessions())
});
sessionRouter.get("/:id",function(req,res){
var session;
try{
session = sessionManager.GetSession(req.param.id);
res.json(session);
}catch(ex){
res.status(404).send(ex);
}
});
app.use('/api', router);
app.use('/api/sessions',sessionRouter);
app.listen(port);
console.log('Magic happens on port ' + port);
When executing the program I get the above named error.
So I did a netstat -anb I get this: all ports
So I tried finding the PORT 8080 or 80 but I just could not find it. If I execute my Node.js Program with a different Port for example: 1000. It works!.
I had the same problem.
What I did was I changed the port of the default website in the IIS-Manager from 8080 to 80 and than I reseted the IIS-Manager. It worked!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With