var express = require(‘express’);
var app = express();
app.get(’./’, function(req,res){
console.log(req);
})
app.listen(4000, function(){
console.log(‘hey there’);
})
on running node temp.js
i m getting output as cannot get /
var express = require(‘express’);
var app = express();
app.get(’./’, function(req,res){
console.log(req);
})
app.listen(4000, function(){
console.log(‘hey there’);
})
on running node temp.js
i m getting output as cannot get /
The above code will print the request details in the console.
You are getting this error because you have not set the response to be rendered when the page hits ‘/’.
Try the code below,
var express = require("express");
var app = express();
app.get('/', function(req, res) {
console.log(req);
});
app.listen(4000, function() {
console.log('hey there');
});
Thanks alot. Now its working but can you please explain me my mistake in detail. Actually m a beginner.
You have made mistake here !!
You need to send a response for the get request. Also you have added a .
before /
thanks for the help.