Tell us what’s happening:
It hours, it unable to figure out whats wrong with my code.
link to problem
Your code so far
var express = require('express');
var app = express();
app.use(function (req, res, next){
console.log(req.method+" "+req.path+" - "+req.ip);
next();
})
console.log("Hello World");
//app.get("/", function(req,res){res.send('Hello Express');} );
app.get('/', function(req, res){res.sendFile( __dirname+'/views/index.html');});
var message;
if(process.env.MESSAGE_STYLE==='uppercase')
message = {"message": "HELLO JSON"};
else
message ={"message" : "Hello json"};
app.use(express.static(__dirname + "/public"));
app.get('/json', function(requst, response){
response.json(message);
});
module.exports = app;
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36
.
Challenge: make root level request logger
Link to the challenge: