Get request cannot find

Get request cannot find
0.0 0

#1

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 /


#2

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');
});

#3

Thanks alot. Now its working but can you please explain me my mistake in detail. Actually m a beginner.


#4

You have made mistake here !!

You need to send a response for the get request. Also you have added a . before /


#5

thanks for the help.